int main()
{
unsigned char names[50][10],tmp[3];
int cnt,i=0,a=0,b=0;
while(1)
{
system("cls");
printf("请输入第%d个同学的姓名:",i+1);
setbuf(stdin,NULL);
gets(names[i]);
if(names[i][0] < 0x80) break;
i++;
}
cnt = i;
for(i=0; i<=cnt; i++)
{
puts(names[i]);
if(i%5==0) puts("\n");
strncpy(tmp,names[i],2);
if(strcmp(tmp,"刘")==0) a++;
}
printf("刘姓学生人数=%d",a);
return 0;
}
哪个字消失了?
i<=cnt? 应该是小于。
– DarkFate 3年前