fork download
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4. public static void main(String[] args) {
  5. Scanner in = new Scanner(System.in);
  6.  
  7. int n = in.nextInt();
  8. int count = 1, space = 0;
  9. for (int i = 1; i < 2 * n; i++) {
  10. if (i <= n) {
  11. space++;
  12.  
  13. } else {
  14. space--;
  15. }
  16.  
  17. for (int spc = n - space; spc > 0; spc--) {
  18. System.out.print(" ");
  19. }
  20. for (int j = 0; j < count; j++) {
  21. System.out.print(i > 9 ? i % 10 : i);
  22. }
  23. if (i < n) {
  24. count = count + 2;
  25. } else {
  26. count = count - 2;
  27. }
  28. System.out.println();
  29. }
  30. in.close();
  31. }
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
8
compilation info
Main.java:3: error: class Test is public, should be declared in a file named Test.java
public class Test {
       ^
1 error
stdout
Standard output is empty