mirror of
https://github.com/xlucn/PAT.git
synced 2026-10-03 00:23:15 +08:00
improve style
This commit is contained in:
+11
-7
@@ -41,16 +41,20 @@ int main()
|
||||
char c;
|
||||
int N, M;
|
||||
scanf("%d %c", &N, &c);
|
||||
|
||||
for(M = 1; 2 * M * M - 1 <= N; M++) ; M--; /* determine the size */
|
||||
|
||||
|
||||
for(M = 1; 2 * M * M - 1 <= N; M++) ;
|
||||
M--; /* determine the size */
|
||||
|
||||
/* draw the sandglass */
|
||||
for(int i = 0; i < 2 * M - 1; i ++){
|
||||
for(int j = 0; j < M - 1 - ABS(M - 1 - i); j++) putchar(' ');
|
||||
for(int j = 0; j < 2 * ABS(M - 1 - i) + 1; j++) putchar(c);
|
||||
for(int i = 0; i < 2 * M - 1; i ++)
|
||||
{
|
||||
for(int j = 0; j < M - 1 - ABS(M - 1 - i); j++)
|
||||
putchar(' ');
|
||||
for(int j = 0; j < 2 * ABS(M - 1 - i) + 1; j++)
|
||||
putchar(c);
|
||||
putchar('\n');
|
||||
}
|
||||
printf("%d", N - 2 * M * M + 1);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user