#include <stdio.h>
#include <string.h>
struct xinxi
{
int id;
char name[30];
int fenshu[3];
};
xinxi shuzhu[100];//设定最大有一百个人
int geshu = 0;//记录个数
int jilu(xinxi* a)//记录用户的输入
{
printf("ID;");
scanf("%d",&a->id );
printf("name;");
scanf("%s",a->name);
printf("fenshu;");
scanf("%d,%d,%d",&a->fenshu[0],&a->fenshu[1],&a->fenshu[2]);
return 0;
}
int chuchun(const xinxi* j)//保存用户的输入
{
shuzhu[geshu] = *j;
geshu += 1;
return 0;
}
void shuchu()//实现菜单功能,,输出所有信息
{
for(int i=0;i<geshu;i++)
{
printf("*******************************************\n");
printf("id;%dname;%sfenshu;%d,%d,%d\n",
shuzhu[i].id ,shuzhu[i].name ,shuzhu[i].fenshu[0],shuzhu[i].fenshu[1],shuzhu[i].fenshu[2]);
printf("*******************************************\n");
}
}
int chaxun(char* a)//实现菜单功能,,可让用户通过名字来查找这个人的信息
{
for(int i=0; i<geshu;i++)
{
if(strcmp(shuzhu[i].name ,a)==0 )
{
printf("jieguo;");
printf("id;%dname;%sfenshu;%d,%d,%d\n",
shuzhu[i].id,shuzhu[i].name,shuzhu[i].fenshu[0],shuzhu[i].fenshu[1],shuzhu[i].fenshu[2]);
break;
}
}
return 0;
}
int main()
{
while(1)
{
printf("qing shuru;");
char mingling[20];//主菜单,,用户来输入指令,然后执行什么功能
scanf("%s",mingling);
if(strcmp(mingling , "0") ==0 )break;//用户输入0,结束程序
if(strcmp( mingling ,"jilu") == 0 )
{
xinxi s;
jilu(&s);
chuchun(&s);
continue;
}
if(strcmp( mingling ,"shuchu")==0 )
{
shuchu();
}
if(strcmp(mingling ,"geshu") ==0 )
{
printf("geshu;%d\n",geshu);
}
if(strcmp(mingling,"chaxun")==0 )
{
printf("name;");
char f[20];
scanf("%s",f);
chaxun(f);
}
else
{
printf("shuru cuowu;");
break;
}
}
return 0;
}
#include <string.h>
struct xinxi
{
int id;
char name[30];
int fenshu[3];
};
xinxi shuzhu[100];//设定最大有一百个人
int geshu = 0;//记录个数
int jilu(xinxi* a)//记录用户的输入
{
printf("ID;");
scanf("%d",&a->id );
printf("name;");
scanf("%s",a->name);
printf("fenshu;");
scanf("%d,%d,%d",&a->fenshu[0],&a->fenshu[1],&a->fenshu[2]);
return 0;
}
int chuchun(const xinxi* j)//保存用户的输入
{
shuzhu[geshu] = *j;
geshu += 1;
return 0;
}
void shuchu()//实现菜单功能,,输出所有信息
{
for(int i=0;i<geshu;i++)
{
printf("*******************************************\n");
printf("id;%dname;%sfenshu;%d,%d,%d\n",
shuzhu[i].id ,shuzhu[i].name ,shuzhu[i].fenshu[0],shuzhu[i].fenshu[1],shuzhu[i].fenshu[2]);
printf("*******************************************\n");
}
}
int chaxun(char* a)//实现菜单功能,,可让用户通过名字来查找这个人的信息
{
for(int i=0; i<geshu;i++)
{
if(strcmp(shuzhu[i].name ,a)==0 )
{
printf("jieguo;");
printf("id;%dname;%sfenshu;%d,%d,%d\n",
shuzhu[i].id,shuzhu[i].name,shuzhu[i].fenshu[0],shuzhu[i].fenshu[1],shuzhu[i].fenshu[2]);
break;
}
}
return 0;
}
int main()
{
while(1)
{
printf("qing shuru;");
char mingling[20];//主菜单,,用户来输入指令,然后执行什么功能
scanf("%s",mingling);
if(strcmp(mingling , "0") ==0 )break;//用户输入0,结束程序
if(strcmp( mingling ,"jilu") == 0 )
{
xinxi s;
jilu(&s);
chuchun(&s);
continue;
}
if(strcmp( mingling ,"shuchu")==0 )
{
shuchu();
}
if(strcmp(mingling ,"geshu") ==0 )
{
printf("geshu;%d\n",geshu);
}
if(strcmp(mingling,"chaxun")==0 )
{
printf("name;");
char f[20];
scanf("%s",f);
chaxun(f);
}
else
{
printf("shuru cuowu;");
break;
}
}
return 0;
}