galinyotsev123

ProgBasics07Nested-Loops-Y03numberTable

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