为什么用C++输出的菱形右边出现字母a
*aa**a****a*aainclude<stdio.h>intmain(){chardiamond[][5]={{'','','*'},{'','*','','*'}...
*aa
* *a
* *
* *a
*aa
include<stdio.h>
int main()
{char diamond[][5]={{' ',' ','*'},{' ','*',' ','*'},{'*',' ',' ',' ','*'},{' ','*',' ','*'},{' ',' ','*'}};
int i,j;
for(i=0;i<5;i++)
{for(j=0;j<5;j++)
printf("%c",diamond[i][j]);
printf("\n");
}
return 0;
} 展开
* *a
* *
* *a
*aa
include<stdio.h>
int main()
{char diamond[][5]={{' ',' ','*'},{' ','*',' ','*'},{'*',' ',' ',' ','*'},{' ','*',' ','*'},{' ',' ','*'}};
int i,j;
for(i=0;i<5;i++)
{for(j=0;j<5;j++)
printf("%c",diamond[i][j]);
printf("\n");
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询