fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static final double xPrecision = 10.0; // (1/xPrecision) is the precision on x-values
  11. static final double yPrecision = 10.0; // (1/yPrecision) is the precision on y-values
  12. static final int PI = (int) (3.1415 * xPrecision);
  13. static final int TPI = 2 * PI; // twice PI
  14. static final int HPI = PI / 2; // half PI
  15.  
  16. public static void main(String[] args) {
  17. double xd;
  18. int[] row = new int[100];
  19. Arrays.fill(row, -1);
  20. int r = 0;
  21. int maxc = 0;
  22. for(int start = (int) (1 * yPrecision), y = start; y >= -start; y--){
  23. double x0 = Math.asin(y / yPrecision),
  24. x1 = bringXValueWithinPrecision(x0),
  25. x2 = bringXValueWithinPrecision(x0 + TPI / xPrecision),
  26. x3 = bringXValueWithinPrecision(PI/xPrecision - x0);
  27. int c = 0;
  28. for(int x = 0; x <= TPI; x++, c++){
  29. xd = (x / xPrecision);
  30.  
  31. if(x1 == xd || x2 == xd || x3 == xd)
  32. row[c] = r;
  33. }
  34. maxc = Math.max(c, maxc);
  35. r++;
  36. }
  37. int[] digit = new int[100];
  38. int current = 0;
  39. for (int i = 0 ; i != maxc ; i++) {
  40. if (row[i] != -1) {
  41. digit[i] = (current++) % 10;
  42. }
  43. }
  44. for (int i = 0 ; i != r ; i++) {
  45. for (int c = 0 ; c != maxc ; c++) {
  46. if (row[c] == i) {
  47. System.out.print(digit[c]);
  48. } else {
  49. System.out.print(' ');
  50. }
  51. }
  52. System.out.println();
  53. }
  54. }
  55.  
  56. public static double bringXValueWithinPrecision(double num){
  57. // obviously num has 16 floating points
  58. // we need to get num within our precision
  59. return Math.round(num * xPrecision) / xPrecision;
  60. }
  61. }
Success #stdin #stdout 0.12s 28980KB
stdin
Standard input is empty
stdout
               01                                              
           9        2                                          
         8            3                                        
        7              4                                       
      6                  5                                     
     5                    6                                    
    4                      7                                   
   3                        8                                  
  2                          9                                 
 1                            0                                
0                              1                              2
                                2                            1 
                                 3                          0  
                                  4                        9   
                                   5                      8    
                                    6                    7     
                                     7                  6      
                                       8              5        
                                        9            4         
                                          0        3           
                                              12