File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments