This commit is contained in:
unlockable
2022-10-27 14:03:17 +08:00
parent bf3b5851d3
commit 6e32ca4ba1
10 changed files with 257 additions and 0 deletions

35
06/Exercise02.c Normal file
View File

@@ -0,0 +1,35 @@
#include <stdio.h>
int main() {
int n, astCount, spaceCount, outAstCount, outSpaceCount;
scanf("%d", &n);
spaceCount = (n-1)/2;
if (n > 2 && n % 2 == 1) {
for(astCount = 1; astCount <= n; astCount+=2){
for (outSpaceCount = 0; outSpaceCount < spaceCount; outSpaceCount++) {
printf(" ");
}
for (outAstCount = 0; outAstCount < astCount; outAstCount++) {
printf("*");
}
printf("\n");
spaceCount--;
}
astCount = n-2;
spaceCount = 1;
for(; astCount > 0; astCount-=2) {
for (outSpaceCount = 0; outSpaceCount < spaceCount; outSpaceCount++) {
printf(" ");
}
for (outAstCount = 0; outAstCount < astCount; outAstCount++) {
printf("*");
}
printf("\n");
spaceCount++;
}
}
else{
printf("input error");
}
return 0;
}