Skip to content

Commit 83fa6e0

Browse files
authored
Create Code : Inverted Number Pattern
1 parent 0ef2bad commit 83fa6e0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Print the following pattern for the given N number of rows.
2+
Pattern for N = 4
3+
4444
4+
333
5+
22
6+
1
7+
Input format :
8+
Integer N (Total no. of rows)
9+
Output format :
10+
Pattern in N lines
11+
Constraints :
12+
0 <= N <= 50
13+
Sample Input 1:
14+
5
15+
Sample Output 1:
16+
55555
17+
4444
18+
333
19+
22
20+
1
21+
Sample Input 2:
22+
6
23+
Sample Output 2:
24+
666666
25+
55555
26+
4444
27+
333
28+
22
29+
1
30+
31+
32+
CODE:
33+
34+
#include<iostream>
35+
using namespace std;
36+
37+
38+
int main(){
39+
40+
/* Read input as specified in the question.
41+
* Print output as specified in the question.
42+
*/
43+
int n;
44+
cin>>n;
45+
for(int i=1; i<=n; i++){
46+
for(int j=n-i+1; j>0; j--){
47+
cout<<n-i+1;
48+
}
49+
for(int space=0; space<n; space++){
50+
cout<<" ";
51+
}
52+
cout<<endl;
53+
}
54+
return 0;
55+
}
56+
57+

0 commit comments

Comments
 (0)