Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class p14_NumTable {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int currentNum = 0;
- int step = 1;
- for (int row = 1; row <= n ; row++) {
- currentNum = row;
- step = 1;
- for (int col = 0; col < n ; col++) {
- System.out.printf("%d ", currentNum);
- if (currentNum >= n){
- step = -1;
- }
- currentNum = currentNum + step;
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement