要打印個空心等腰梯形,輸入n為3,麻煩看下我的程序哪裡錯了
↵
#include
int main(void){
int n,i,j;
printf("Input n: ");
scanf("%d",&n);
for (i=1;i<=n;i++){
if (i==1||i==n){
for (j=1;j<=n-i;j++)
printf(" ");
for(j=n-j+1;j<=n+i+1;j++)
printf("*");
printf("\n");}
else
for (j=1;j<=n-i;j++){
printf(" ");
if (j==i||j==3*i+1)
printf("*");
printf("\n");}
}}
Input n: 6
*******
* *
* *
* *
* *
*****************
Press any key to continue