中易网

学生通讯信息包括:序号、姓名、班级、手机号、E-mail号、宿舍号等

答案:5  悬赏:70  
解决时间 2021-03-23 23:02
主要功能与要求1:能建立,修改和删除学生通讯录
2能够按多种方式进行查询
3按菜单方式操作
最佳答案
说明:保存程序源代码时,必须以.C为后缀名.
详细的程序代码如下:(给出了详细的解释,本程序在VC6.0或TC2.0都编译通过)
#include
#include
#include
#include
#include
typedef struct student
{
char sequenceNumber[10];
char name[20];
char classNumber[20];
char telephone[20];
char E_mail[20];
char dormitoryNumber[10];
struct student *next;
}student;
student *headLink;

void DesplayMenu(void);
void CreateHeadLink(void);
student *MallocNode(void);
void GetInformation(student *t);
void OutputInformation(void);
void classNumberBytelephone(void);
void DesplayInfoBysequenceNumber(void);
void DesplayOneNode(student *t);
void InsertOneNode(student *t);
void DeleteNodeBysequenceNumber(void);
void DesplayInfoByName(void);
int choose;

void main()
{
CreateHeadLink();
DesplayMenu();
}

void DesplayMenu(void)
{
student *p;
printf("\n-------请选择相应功能-------------\n\n");
printf("| 1 显示所有学生信息 |\n");
printf("| 2 按学生序号高到低排序 |\n");
printf("| 3 根据学生序号查询学生的信息 |\n");
printf("| 4 根据学生姓名查询学生的信息 |\n");
printf("| 5 增加一个学生 |\n");
printf("| 6 删除某一学生 |\n");
printf("| 7 退出 |\n\n");
scanf("%d",&choose);
switch(choose)
{
case 1:
OutputInformation();
break;
case 2:
classNumberBytelephone();
break;
case 3:
DesplayInfoBysequenceNumber();
break;
case 4:
DesplayInfoByName();
break;
case 5:
p=MallocNode();
GetInformation(p);
InsertOneNode(p);
break;
case 6:
DeleteNodeBysequenceNumber();
break;
case 7:
free(headLink);
exit(1);
break;
default:
break;
}
DesplayMenu();
}

void CreateHeadLink(void)
{
student *p;
p=(student*)malloc(sizeof(student));
headLink=p;
p->next=NULL;
}

student *MallocNode(void)
{
student *p;
int i;
p=(student*)malloc(sizeof(student));
if(p==NULL)
return NULL;
for(i=0;i<10;i++)
p->sequenceNumber[i]='\0';
for(i=0;i<20;i++)
p->classNumber[i]='\0';
for(i=0;i<20;i++)
p->name[i]='\0';
for(i=0;i<20;i++)
p->E_mail[i]='\0';
for(i=0;i<10;i++)
p->dormitoryNumber[i]='\0';
for(i=0;i<10;i++)
p->telephone[i]='\0';
p->next=NULL;
return p;
}

void GetInformation(student *t)
{
printf("请输入序号:\n");
scanf("%s",t->sequenceNumber);
printf("请输入班级:\n");
scanf("%s",t->classNumber);
printf("请输入姓名:\n");
scanf("%s",t->name);
printf("请输入电话:\n");
scanf("%s",t->telephone);
printf("请输入Email:\n");
scanf("%s",t->E_mail);
printf("请输入宿舍号:\n");
scanf("%s",t->dormitoryNumber);
}

void InsertOneNode(student *t)
{
student *p;
p=headLink;
while(p->next)
{
p=p->next;
}
p->next=t;
}

void DesplayInfoBysequenceNumber(void)
{
student *p;
char good[10];
char flag=0;
p=headLink->next;
if(p==NULL)
{
printf("对不起,现在没有学生信息!\n");
return;
}
printf("请输入序号:\n");
scanf("%s",good);
while(p)
{
if(strcmp(p->sequenceNumber,good)==0)
{
DesplayOneNode(p);
flag=1;
break;
}
p=p->next;
}
if(!flag)
printf("对不起,不存在序号为 %s 的学生\n",good);
}

void DesplayInfoByName(void)
{
student *p;
char name[10];
char flag=0;
p=headLink->next;
printf("请输入姓名:\n");
scanf("%s",name);
while(p)
{
if(strcmp(p->sequenceNumber,name)==0)
{
DesplayOneNode(p);
flag=1;
break;
}
p=p->next;
}
if(!flag)
printf("对不起,不存在姓名为 %s 的学生\n",name);
}

void DesplayOneNode(student *t)
{
printf("%s\t",t->sequenceNumber);
printf("%s\t",t->classNumber);
printf("%s\t",t->name);
printf("%s\t",t->telephone);
printf("%s\t",t->E_mail);
printf("%s\t\n",t->dormitoryNumber);
}

void DeleteNodeBysequenceNumber(void)
{
char good[10];
student *p,*q;
char flag=0;
printf("请输入要删除的学生序号:");
scanf("%s",good);
p=headLink;
q=headLink->next;
while(q)
{
if(strcmp(q->sequenceNumber,good)==0)
{
p->next=q->next;
free(q);
flag=1;
break;
}
p=p->next;
q=q->next;
}
if(!flag)
printf("不存在这学生\n");
}

void OutputInformation(void)
{
student *p;
p=headLink->next;
if(p==NULL)
{
printf("现在没有学生信息,请先输入学生\n\n");
return;
}
printf("序号\t班级\t姓名\t电话\t邮箱\t宿舍号\t\n");
while(p)
{
DesplayOneNode(p);
p=p->next;
}
}

void classNumberBytelephone(void)
{
char classNumber[20];
student exchange,*r,*p,*q;
r=headLink->next;
if(r==NULL)
{
printf("现在还没学生信息,请先输入学生信息\n");
return;
}
printf("请输入班级名:\n");
scanf("%s",classNumber);
while(r)
{
p=r;
q=r->next;
while(q)
{
if((strcmp(p->sequenceNumber,q->sequenceNumber)>0)
&&(strcmp(p->classNumber,classNumber)==0)
&&(strcmp(q->classNumber,classNumber)==0))
{
strcpy(exchange.sequenceNumber,q->sequenceNumber);
strcpy(exchange.E_mail,q->E_mail);
strcpy(exchange.dormitoryNumber,q->dormitoryNumber);
strcpy(exchange.name,q->name);
strcpy(exchange.classNumber,q->classNumber);
strcpy(exchange.telephone,q->telephone);
strcpy(q->sequenceNumber,p->sequenceNumber);
strcpy(q->E_mail,p->E_mail);
strcpy(q->dormitoryNumber,p->dormitoryNumber);
strcpy(q->name,p->name);
strcpy(q->classNumber,p->classNumber);
strcpy(q->telephone,p->telephone);
strcpy(p->sequenceNumber,exchange.sequenceNumber);
strcpy(p->E_mail,exchange.E_mail);
strcpy(p->dormitoryNumber,exchange.dormitoryNumber);
strcpy(p->name,exchange.name);
strcpy(p->classNumber,exchange.classNumber);
strcpy(p->telephone,exchange.telephone);
}
q=q->next;
}
r=r->next;
}
}
全部回答
问 你是要建立个后台吗?
#include "stdio.h" #include #include #define PHONE struct phone #define LEN sizeof(PHONE) PHONE { char name[20]; char pnum[11]; char *qq; char bzhu[10]; char email[28]; PHONE *next; }; int n; PHONE *creat(void) { PHONE *head,*p1,*p2; n=0; p1=p2=(PHONE *)malloc(LEN); printf("qing shu ru name,phonenum,beizhu,qq,email\n"); scanf("%s",p1->name); gets(p1->pnum); getchar(); gets(p1->bzhu); scanf("%s%s",p1->qq,p1->email); head=NULL; while(p1->name!=0); { n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(PHONE *)malloc(LEN); printf("qing shu ru name,phonenum,beizhu,qq,email\n"); gets(p1->name); gets(p1->pnum); gets(p1->bzhu); scanf("%s%s",p1->qq,p1->email); } p2->next=NULL; return head; } PHONE *del(PHONE *head,char name[20]) { PHONE *p1,*p2; if(head==NULL) { printf("\nthe list is null\n"); goto end; } p1=head; while(strcmp(name,p1->name)!=0&&p1->next!=NULL) { p2=p1; p1=p1->next; } if(strcmp(name,p1->name)==0) { if(p1==head) head=p1->next; else p2->next=p1->next; printf("delete:%s\n",name); n=n-1; } else printf("%s not been found!\n",name); end: return head; } void print(PHONE *head) { PHONE *p; int i; for(i=0;iname,p->pnum,p->qq,p->email,p->bzhu); p=p->next; }while(p!=NULL); } PHONE *insert(PHONE *head,PHONE *stud) { PHONE *p0,*p1,*p2; p1=head; p0=stud; if(head==NULL) { head=p0; p0->next=NULL; } else { while((strcmp(p0->name,p1->name)>0) &&( p1->next!=NULL)) { p2=p1; p1=p1->next; } if(strcmp(p0->name,p1->name)<0) { if(head==p1) head=p0; else p2->next=p1; p0->next=p1; } else { p1->next=p0; p0->next=NULL; } } n=n+1; return head; } void makefile(PHONE *head) { FILE *fp; PHONE *sj,*p; char ch,filename[10]; printf("qing shu ru wen jian ming:\n"); scanf("%s",filename); if(fp=fopen("filename","w")==NULL) { printf("bu neng da kai wen jian %s!!\n",filename); exit(0); } ch=getchar(); p=head; while(p!=0&&p->next!=NULL) { fwrite(&filename,sizeof(LEN),1,fp); if(fwrite(&filename,sizeof(LEN),1,fp)!=1) { printf("write erro
我只有c++的。
--------------------Configuration: txun - Win32 Debug-------------------- Compiling... txun.cpp E:\作业\ch11\txun\txun.cpp(68) : error C2065: 'strcmp' : undeclared identifier E:\作业\ch11\txun\txun.cpp(147) : error C2440: '=' : cannot convert from 'bool' to 'struct _iobuf *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast E:\作业\ch11\txun\txun.cpp(172) : error C2440: '=' : cannot convert from 'struct _iobuf *' to 'struct phone *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast E:\作业\ch11\txun\txun.cpp(178) : error C2562: 'read' : 'void' function returning a value E:\作业\ch11\txun\txun.cpp(167) : see declaration of 'read' E:\作业\ch11\txun\txun.cpp(238) : error C2039: 'next' : is not a member of '_iobuf' c:\program files\microsoft visual studio\vc98\include\stdio.h(146) : see declaration of '_iobuf' E:\作业\ch11\txun\txun.cpp(238) : fatal error C1903: unable to recover from previous error(s); stopping compilation 执行 cl.exe 时出错. txun.obj - 1 error(s), 0 warning(s)
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
求康师傅牛肉面酱料包配方
20年轻买了个400的玉手镯现在值多少钱
请以“手握试卷”为题目,写一篇作文,要求:
世界名桥有哪些
爸爸给小雨买了一辆自行车,原价360元,现在
麻烦问一下,交通银行异地跨行跨省取款多少手
手机游戏手指滑板怎么玩啊!急…………
2016年消防湿式报警阀有没有强制性要求
12个时辰怎么算
请问住浦东东方路兰陵路到浦东新区陆家嘴滨江
垫底辣妹里的双马尾女孩是谁演的
多个螺钉一起锁紧遇到的问题
宝安西乡和民治哪里环境好
中药的煎煮法
去疤痕用什么方法能好的快一点?
推荐资讯
有人用过妈咪知道这个APP么?好用么?
21度适合穿什么
济大西校区菜鸟驿站在西门怎么走
浙江二建建筑安装工程公司 施工员都干什么呢
卡地亚戒指六彩宝的要多少钱?
平时不化妆,最多是涂点BB霜、唇彩简单了事。
梦见姐姐死了,没见到血,就是躺在床上,这个
已知点A(3,1),B(0,0)C(3,0).设∠B
一直觉得关系不错的朋友,却疏远了自己,说话
ssd做系统盘 一定要接在第一个SATA接口上吗?
娇韵诗瘦身霜价格
湖北武汉那杨浦减肥训练营价格贵不贵,可不可
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?