请问这个程序有什么问题,为什么运行不了

来源:百度知道 编辑:UC知道 时间:2024/05/29 16:03:40
#include<stdio.h>
void main()
{
char str[5]={'*','*','*','*','*'}
int i,j,k;
char space=' ';
for(i=0;i<5;i++)
{
printf("\n");
printf(" ");
for(j=1;j<5;j++)
printf("%c",space);
for(k=0;k<5;k++)
printf("%c",str[k]);
}
printf("\n");
}

(1)char str[5]={'*','*','*','*','*'} 后缺分号
(2)
for(j=1;j<5;j++)
printf("%c",space);
for(k=0;k<5;k++)
printf("%c",str[k]);
是不是应该这样:
for(j=i;j<5;j++)
{
printf("%c",space);
for(k=0;k<5;k++)
printf("%c",str[k]);
}

char str[5]={'*','*','*','*','*'} (分号)
int i,j,k;

还有你for后面应该跟上{} 还有缩进也要注意!!
for(j=1;j<5;j++)
{
printf("%c",space);
}
for(k=0;k<5;k++)
{
printf("%c",str[k]);
}