galinyotsev123

ProgBasicsJavaBook7.1ComplexLoop16numberTable

Jan 15th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class E16numberTable {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. int n = Integer.parseInt(scanner.nextLine());
  9.  
  10. for (int row = 0; row < n; row++) {
  11. for (int col = 0; col < n; col++) {
  12. int num = row + col + 1;
  13. if (num > n) {
  14. num = 2 * n - num;
  15. }
  16. System.out.print(num + " ");
  17. }
  18. System.out.println();
  19. }
  20.  
  21.  
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment