fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8. int tmpSize = 9; //default
  9. final Scanner scanner = new Scanner(System.in);
  10. if (scanner.hasNextInt()) {
  11. tmpSize = scanner.nextInt();
  12. }
  13. scanner.close();
  14.  
  15. final int size = tmpSize;
  16. for (int i = 0 ; i < size; i++) {
  17. for (int j = 0; j < size; j++) {
  18. System.out.print(j == i || j == size - i - 1 ? 'x' : ' ');
  19. }
  20. System.out.println();
  21. }
  22. }
  23. }
  24.  
Success #stdin #stdout 0.15s 321280KB
stdin
Standard input is empty
stdout
x       x
 x     x 
  x   x  
   x x   
    x    
   x x   
  x   x  
 x     x 
x       x