-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathPattern29.java
More file actions
38 lines (38 loc) · 788 Bytes
/
Pattern29.java
File metadata and controls
38 lines (38 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.java.patterns;
import java.util.Scanner;
/*
Write the program to print the following pattern
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
*/
public class Pattern29 {
public static void main(String args[] ) throws Exception {
Scanner scanner = new Scanner(System.in);
int N = Integer.parseInt(scanner.nextLine());
for(int i=0;i<N;i++){
for(int j = 0;j<i;j++)
System.out.print(" ");
for(int j=i;j<N;j++)
if(j == i)
System.out.print(N-i);
else
System.out.print(" "+(N-i));
if(i != N-1)
System.out.println();
}
scanner.close();
}
}
/*
Input
5
Output
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
*/