用c语言编写先存储一个班级学生的姓名,从键盘输入一个姓名,查找该人是否为该班学生?

[复制链接]
查看11 | 回复2 | 2011-6-27 02:10:55 | 显示全部楼层 |阅读模式
回复

使用道具 举报

千问 | 2011-6-27 02:10:55 | 显示全部楼层
charname[100][10],s[10];
intf=0;
班级学生的姓名输入略;
scanf(\"%s\",s);
for(i=0;i100;i)
if(strcmp(name,s)==0)
f=1;

f=1;则该人为该班学生

string.h









<h4class=\"ask\">追问


求完整版
回复

使用道具 举报

千问 | 2011-6-27 02:10:55 | 显示全部楼层
#includestdio.h
#includestring.h

intmain()
{
charname[100][10],s[10];
inti,f=0;
for(i=0;i100;i)
{
printf(\"student%d\",i1);
scanf(\"%s\",name);
}

scanf(\"%s\",s);
for(i=0;i100;i)
if(strcmp(name,s)==0)
f=1
if(f==1)
printf(找到该学生\");
elseprintf(未找到该学生\");
return0;
getchar();
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行