Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Homework_Loops;
- import java.util.Scanner;
- public class PO9_MatrixOfNumbers_2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Enter n: (1 ≤ n ≤ 20) ");
- int n = Integer.parseInt(scanner.nextLine());
- //The outer loop must run from 1 to N,
- // the inner loop – from the value of the outer loop to the value of the outer loop + N - 1.
- for (int i = 1; i <= n; i++)
- {
- for (int j = i; j <= i+n-1; j++)
- {
- System.out.print(j + " ");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment