improve style

This commit is contained in:
Oliver Lew
2019-01-08 23:45:51 +08:00
parent ad67fde6d3
commit 8f6d2399fa
+11 -7
View File
@@ -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;
}