-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumberpattern16.cpp
More file actions
36 lines (36 loc) · 896 Bytes
/
numberpattern16.cpp
File metadata and controls
36 lines (36 loc) · 896 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
#include <iostream>
using namespace std;
main(){
int i,j,n;
cin>>n;
for(i=n;i>=1;i--){
for(j=n;j>i;j--){
cout<<j;
cout<<" "; //5 5 5 5 5 5 5 5 5
} //5 4 4 4 4 4 4 4 5
for(j=1;j<=((2*i)-1);j++){ //5 4 3 3 3 3 3 4 5
cout<<i; //5 4 3 2 2 2 3 4 5
cout<<" "; //5 4 3 2 1 2 3 4 5
} //5 4 3 2 2 2 3 4 5
for(j=(i+1);j<=n;j++){ //5 4 3 3 3 3 3 4 5
cout<<j; //5 4 4 4 4 4 4 4 5
cout<<" "; //5 5 5 5 5 5 5 5 5
} //number pattern problem
cout<<endl;
}
for(i=2;i<=n;i++){
for(j=n;j>=(i+1);j--){
cout<<j;
cout<<" ";
}
for(j=1;j<=((2*i)-1);j++){
cout<<i;
cout<<" ";
}
for(j=(i+1);j<=n;j++){
cout<<j;
cout<<" ";
}
cout<<endl;
}
}