-
Notifications
You must be signed in to change notification settings - Fork 359
/
square.c
48 lines (47 loc) · 853 Bytes
/
square.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
#include<stdio.h>
int main()
{
int i,j,k,l,m,n,o=2,a,b,c,d,g,h;
printf("enter the last digit of square");
scanf("%d",&n);
b=n-1;
for(i=n;i>=1;i--)
{
m=n;
for(l=1;l<=n-i;l++)
{
printf("%d ",m);
m--;
}
for(j=1;j<=2*i-1;j++)
{
printf("%d ",i);
}
o=i+1;
for(k=1;k<=n-i;k++)
{
printf("%d ",o);
o++;
}
printf("\n");
}
for(a=1;a<=b;a++)
{
d=n;
for(c=1;c<=b-a;c++)
{
printf("%d ",d);
d--;
}
for(g=1;g<=2*a+1;g++)
{
printf("%d ",a+1);
}
for(h=1;h<=b-a;h++)
{
printf("%d ",a+h+1);
}
printf("\n");
}
return 0;
}