-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1027.c
43 lines (39 loc) · 771 Bytes
/
1027.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
#include<stdio.h>
#include<math.h>
int main()
{
int n, m, r;
int p[25], q[25];
char s;
scanf("%d", &n);
getchar();
scanf("%c", &s);
m = sqrt((n + 1) / 2);
r = n - 2 * pow(m, 2) + 1;
for(int i = 0; i < m; i ++){
p[i] = 2 * (i + 1) - 1;
q[i] = 2 * (i + 1) - 1;
}
for(int i = m -1; i >=0 ; i--){
int j = m - i - 1;
while(j--){
putchar(' ');
}
while(p[i]--){
printf("%c", s);
}
printf("\n");
}
for(int i = 1; i < m; i++){
int j = m - i - 1;
while(j--){
putchar(' ');
}
while(q[i]--){
printf("%c", s);
}
printf("\n");
}
printf("%d", r);
return 0;
}