-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern7.cpp
More file actions
49 lines (44 loc) · 834 Bytes
/
pattern7.cpp
File metadata and controls
49 lines (44 loc) · 834 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
39
40
41
42
43
44
45
46
47
48
49
/*PROGRAM TO PRINT PATTERN
1
1 2 3
1 2 3 4 5
1 2 3
1
FOR N=5 AND SO ON */
#include<iostream>
using namespace std;
int main()
{
int n,row,col,k,j;
cin>>n;
row=1,k=1,j=1;
while(row<=n)
{
col=1;
j=1;
while(col<=n)
{
if(col<=n/2+1-k || col>=n/2+1+k)
cout<<" ";
else
{
cout<<j;
j=j+1;
}
col=col+1;
}
cout<<endl;
row=row+1;
if(row<=n/2+1)
{
k=row;
j=row;
}
else
{
k=n+1-row;
j=n+1-row;
}
}
return 0;
}