-
Notifications
You must be signed in to change notification settings - Fork 0
/
pat31.c
70 lines (60 loc) · 990 Bytes
/
pat31.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <string.h>
int printBlank(int n)
{
int i = 0;
for( i = 0; i < n; i++ )
{
printf(" ");
}
return 0;
}
int procs(char *str)
{
int len = strlen(str);
int i = 0, j = 0;
int times = len/3 + ((len%3==0)?0:1);
for( i = 0; i < times; i++ )
{
if( i != times - 1 )
{
printf("%c", str[i]);
if( len % 3 == 0 )
{
printBlank( len / 3 );
}
else
{
printBlank(len % 3 + len / 3 - 2);
}
printf("%c\n", str[len - 1 - i]);
}
else
{
if( len % 3 == 0 )
{
for( j = 0; j < (len % 3 + len / 3 + 2); j++ )
{
printf("%c", str[j+times - 1]);
}
}
else
{
for( j = 0; j < (len % 3 + len / 3); j++ )
{
printf("%c", str[j+times - 1]);
}
}
printf("\n");
}
}
return 0;
}
int main()
{
int num;
char str[90];
scanf("%s", str);
procs(str);
return 0;
}