Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter your number: ");
- int num = Integer.parseInt(sc.nextLine());
- for(int row = 0; row < num;row++){
- for(int col = 0;col < num;col++){
- int number = col+row+1;
- if(number > num){
- number = 2*num-number;
- }
- System.out.print(number + " ");
- }
- System.out.println();
- }
- }
- }
Add Comment
Please, Sign In to add comment