-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberpattern.cpp
More file actions
47 lines (46 loc) · 778 Bytes
/
Numberpattern.cpp
File metadata and controls
47 lines (46 loc) · 778 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
//For pattern n=4
/* 1
232
34543
4567654
*/
#include <iostream>
#include<math.h>
#define ll long long
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a=1;
int odd=1;
for(int i=0;i<n;i++)
{
a=i+1;
for(int j=0;j<n-i-1;j++)
{
cout<<" ";
}
for(int k=1;k<=odd;k++)
{
if(k>odd/2)
{
cout<<a;
a--;
}
else
{
cout<<a;
a++;
}
}
odd+=2;
cout<<endl;
}
}
return 0;
}