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. public static void main(String[] args) {
  11. char screen[][]=new char[20][20];
  12. for(int y=0;y<screen.length;y++)
  13. for(int x=0;x<screen[y].length;x++)
  14. screen[y][x]=' ';
  15. kreis(screen,10,10,7,'*');
  16. for(char line[]: screen){
  17. for(char c: line)
  18. System.out.print(c);
  19. System.out.println();
  20. }
  21. }
  22.  
  23. public static char[][] kreis(char[][] zf, int xM, int yM, int r, char z){
  24. for(int i=-r;i<=r;i++){
  25. int j=(int)Math.round(Math.sqrt(r*r-i*i));
  26. int x=xM+i;
  27. int y=yM+j;
  28. if(x>0 && y>0 && y<zf.length && x<zf[0].length)
  29. zf[y][x]=z;
  30. y=yM-j;
  31. if(x>0 && y>0 && y<zf.length && x<zf[0].length)
  32. zf[y][x]=z;
  33. x=xM+j;
  34. y=yM+i;
  35. if(x>0 && y>0 && y<zf.length && x<zf[0].length)
  36. zf[y][x]=z;
  37. x=xM-j;
  38. if(x>0 && y>0 && y<zf.length && x<zf[0].length)
  39. zf[y][x]=z;
  40. }
  41. return zf;
  42. }
  43. }
Success #stdin #stdout 0.06s 2184192KB
stdin
Standard input is empty
stdout
                    
                    
                    
        *****       
      **     **     
     *         *    
    *           *   
    *           *   
   *             *  
   *             *  
   *             *  
   *             *  
   *             *  
    *           *   
    *           *   
     *         *    
      **     **     
        *****