forked from kushalsingh-00/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pat1.c
52 lines (48 loc) · 867 Bytes
/
pat1.c
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
50
51
52
/*
-------------------------------------------------------
Name : Pattern
Author : Kushal Singh Rathore
Discription : Concentric Square
-------------------------------------------------------
*
//let n=3
/*
33333
32223
32123
32223
33333
*/
#include<stdio.h>
int main()
{
int i,j,k,n;
scanf("%d",&n);
for(i=1;i<2*n;i++)
{
k=n;
if(i<=n)
{
for(j=1;j<2*n;j++)
{
printf("%d",k);
if(i>j)
k=k-1;
if(i+j>=2*n)
k=k+1;
}
}
if(i>n)
{
for(j=1;j<2*n;j++)
{
printf("%d",k);
if(i<=j)
k=k+1;
if(i+j<2*n)
k=k-1;
}
}
printf("\n");
}
}