首页 vc学生信息管理系统

vc学生信息管理系统

举报
开通vip

vc学生信息管理系统vc学生信息管理系统 vc学生信息管理系统 悬赏分:0 - 解决时间:2008-6-11 16:46 1)能够从屏幕上读取一个学生的信息并将信息存入到数据文件中。 2)能够将指定的信息从文件中删除。 3)能够按编号、姓名对学生的信息进行检索并将检索结果显示在屏幕上。 4)可以统计全部学生的总成绩,及其在班上的排名。 5)能够统计各科的平均成绩及及格率。 6)要求有错误提示功能,例如性别只能输入男女,输入错误提示重新输入。 7)如果检索不到相应的信息应提示用户。 #include #include #includ...

vc学生信息管理系统
vc学生信息管理系统 vc学生信息管理系统 悬赏分:0 - 解决时间:2008-6-11 16:46 1)能够从屏幕上读取一个学生的信息并将信息存入到数据文件中。 2)能够将指定的信息从文件中删除。 3)能够按编号、姓名对学生的信息进行检索并将检索结果显示在屏幕上。 4)可以统计全部学生的总成绩,及其在班上的排名。 5)能够统计各科的平均成绩及及格率。 6)要求有错误提示功能,例如性别只能输入男女,输入错误提示重新输入。 7)如果检索不到相应的信息应提示用户。 #include #include #include #include #include #include #include #include #include //#define NULL 0 int const Q=20; #define LEN sizeof(struct student) using namespace std; int n=0; //定义一个全局变量统计学生人数 //——--------->定义一个学生考试信息的结构体 struct student { char name[Q]; //用来存放姓名的 char sex[Q]; //用来存放性别的 long int id; //用来存放准考证号的 int score[4]; //用来存放分数的 int total; //用来存放总分数的 struct student *next; }; //student向量容器 vector stu; //-------------->学生类 class Information { public: Information() ; //构造函数. ~Information() ; //析构函数. student *creat();//建立链 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 函数。 void output(student *head); int count(student *head);//定义函数count()统计考生总数 student *insert(student*head);//指针函数*insert()用来添加考生信息. student *cancel(student *head,long int num);//指针函数*cancel()用来删除考生信息. student *find(student *head,long int num); //指针函数*find()用来查找考生信息. void inorder(student *head);//定义inorder()函数将考生的总分从大到小排列并输出 void average( student *head);//求学生成绩的平均分的函数 void save(student *head);//保存函数 student *Read();//读取函数 private: student *p1,*p2,*p3,*head,st; }; Information::Information() { cout<<" ******************************************************************************\n"; cout<<" ------------------------<<欢迎您使用学生成绩管理系统>>------------------------\n"; cout<<" ******************************************************************************\n\n"; } Information::~Information() { cout<<" ******************************************************************************\n"; cout<<" ------------------------<<谢谢您使用学生成绩管理系统>>------------------------\n"; cout<<" ******************************************************************************\n"; } student *Information::creat(void) {//定义一个指向struct student的结构体指针函数*creat()用来增加考生信息. char ch[Q];n=0; //用来存放姓名的 p1=p2=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元 cout<<" -------------<<请建立学生考试信息表,在姓名处键以 ! 结束输入。>>--------------"<>ch; head=NULL; //给指针head赋初值 while (strcmp(ch,"!")!=0) {//调用字符比较函数strcmp()用来判断是否继续输入 char str[10]; int flag=0; p1=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元 strcpy(p1->name,ch); //将循环结构前面输入的姓名复制到结构体名为p1的数组name中 cout<<" 性别:"; cin>>p1->sex; cout<<" 准考证号(8位):"; do{ cin>>str; if(atol(str)>99999999 || atol(str)<1) cout<<"对不起,请正确输入!!!\n"; else { p1->id=atol(str); flag=1; } }while(flag==0); flag=0; cout<<" 计算机组成原理成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[0]=atoi(str); flag=1; } }while(flag==0); flag=0; cout<<" 概率统计成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[1]=atoi(str); flag=1;} }while(flag==0); flag=0; cout<<" 英语成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[2]=atoi(str); flag=1;} }while(flag==0); flag=0; cout<<" C++成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[3]=atoi(str); flag=1;} }while(flag==0); flag=0; p1->total=p1->score[0]+p1->score[1]+p1->score[2]+p1->score[3];//计算总分 if(n==0)head=p1;//如果是输入第一组学生考试信息就将指针p1赋给指针head else p2->next=p1;//否则将p1赋给p2所指结构体的next指针 p2=p1;//将指针p1赋给指针p2 n++; //将n的值加1 cout<<" 姓名:"; cin>>ch;//将输入的姓名存放到字符数组ch中 } p2->next=NULL;//将p2所指结构体的next指针重新赋空值 return (head);//将输入的第一组学生考试信息返回 } //--------------->定义output()函数将考生的信息从头指针所指内容开始输出 void Information::output(student *head) { if(head==NULL) cout<<" 这是一个空表,请先输入考生成绩.\n"; else{ cout<<"-------------------------------------------------------------------------------\n"; cout<<" *学生考试成绩信息表*\n"; cout<<"-------------------------------------------------------------------------------\n"; cout<<"准考证号 姓 名 性别 计算机组成原理 概率统计 英语 C++ 平均分 总分\n"; cout<<"-------------------------------------------------------------------------------\n"; p1=head;//将头指针赋给p do { cout<id <name <sex <score[0] <score[1] <score[2] <score[3] <total/4.0 <total<next;//将下一组考生信息的next指针赋给p }while(p1!=NULL);//若指针p非空则继续,目的是把所有的考生信息都传给指针p然后输出. } } //------------>统计学生人数的函数 int Information::count(struct student *head)//定义函数count()统计考生总数 { if(head==NULL) return(0);//若指针head为空返回值为0 else return(1+count(head->next));//函数的递归调用 } //----------->插入学生的成绩的函数 student *Information::insert( student *head) //插入新结点定义一个指向struct student的结构体指针函数*insert()用来添加考生信息. { char str[10]; int flag=0; cout<<"\t----------------<<请输入新增学生成绩信息>>----------------\n"<>p1->name; //将输入的姓名存放到结构体名为p1的数组name中 cout<<" 性别:"; cin>>p1->sex; cout<<" 准考证号(8位):"; do{ cin>>str; if(atol(str)>99999999 || atol(str)<1) cout<<"对不起,请请正确输入!!!\n"; else {p1->id=atol(str); flag=1; } }while(flag==0); flag=0; cout<<" 计算机组成原理成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[0]=atoi(str); flag=1;} }while(flag==0); flag=0; cout<<" 概率统计成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[1]=atoi(str); flag=1;} }while(flag==0); flag=0; cout<<" 英语成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[2]=atoi(str); flag=1;} }while(flag==0); flag=0; cout<<" C++成绩:"; do{ cin>>str; if(atoi(str)>100 || atoi(str)<1) cout<<"对不起,请输入1-100之间的数字!!\n"; else { p1->score[3]=atoi(str); flag=1;} }while(flag==0); flag=0; p1->total=p1->score[0]+p1->score[1]+p1->score[2]+p1->score[3];//计算总分 p2=head;//将头指针赋给p2 if(head==NULL) //若没调用次函数以前的头指针head为空 { head=p1;p1->next=NULL; }//则将p1赋给头指针head并将p1所指结构体成员指针next赋空值 else { while((p1->id>p2->id)&&(p2->next!=NULL)) { p3=p2;//p3指向原p2指向的结点 p2=p2->next; }//p2后移一个结点 if(p1->id<=p2->id) { if(head==p2) { p1->next=head; head=p1; } //插入到第一个结点之前 else { p3->next=p1; p1->next=p2; } //插入到p3所指结点之后 } else { p2->next=p1; p1->next=NULL; } //插入到尾结点之后 } n++;//将学生人数加1 cout<<"\t你输入的学生信息已经成功插入"<删除函数 student *Information::cancel(student *head,long int num)//定义一个指向struct student的结构体指针函数*delete()用来删除考生信息. { if(head==NULL)//若调用次函数以前的头指针head为空 { return(head); } else { p1=head;//否则将头指针赋给p1 while(num!=p1->id&&p1->next!=NULL)//寻找要删除的结点当p1所指的学生准考证号不是输入的学生准考证号并且p1所指的next指针不为空 { p2=p1; p1=p1->next; }//p2指向原p1指向的结点p1后移一个结点 if(num==p1->id)//如果输入的学生准考证号是p1所指的学生准考证号//结点找到后删除 { if(p1==head) head=p1->next;//如果head指针和p1指针相等则将下一个结点赋给指针head else p2->next=p1->next;//否则将p1所指结点赋给p2所指结点将要删除的学生信息跳过去 cout<<" 删除准考证号为"<查找函数 student *Information::find(student *head,long int num) //定义一个指向struct student的结构体指针函数*find()用来查找考生信息. { if(head==NULL)//若调用次函数以前的头指针head为空 { cout<<" 这是一个空表,请先输入考生成绩.\n"; return(head); } else { p1=head;//否则将头指针赋给p1 while(num!=p1->id&&p1->next!=NULL) //寻找结点当p1所指的学生准考证号不是输入的学生准考证号并且p1所指的next指针不为空 { p1=p1->next; }//p2指向原p1指向的结点p1后移一个结点 if(num==p1->id)//如果要查找的学生准考证号是p1所指的学生准考证号 { cout<<"------------------------------------------------------------------------------\n"; cout<<"准考证号 姓名 性别 计算机组成原理 概率统计 英语 C++ 平均分 总分 \n"; cout<<"------------------------------------------------------------------------------\n"; cout<id <name <sex <score[0] <score[1] <score[2] <score[3] <total/4.0 <total<next; } for(k=0;ktotaltotal) { p2=p[k]; p[k]=p[j]; p[j]=p2; } //从大到小排列的指针 for(i=0;iid <name <sex <score[0] <score[1] <score[2] <score[3] <total/4.0 <total<求各科平均分成绩的函数 void Information::average(student *head) { int k,m; float arg1=0,arg2=0,arg3=0,arg4=0; if(head==NULL)//如果头指针是空则继续 { cout<<" 这是一个空表,请先输入考生成绩.\n"; } else { m=count(head); p1=head; for(k=0;kscore[0]; arg2+=p1->score[1]; arg3+=p1->score[2]; arg4+=p1->score[3]; p1=p1->next; } arg1/=m;arg2/=m;arg3/=m;arg4/=m; cout<<"全班单科成绩平均分\n"; cout<<"------------------------------------------------------------------------------\n"; cout<<" 计算机组成原理平均分:"<保存函数. void Information::save(student *head) { ofstream out("data.txt",ios::out); out<name<<"\t" <id<<"\t"<<"\t" <sex<<"\t" <score[0]<<"\t" <score[1]<<"\t" <score[2]<<"\t" <score[3]<<"\t" <total<next; } } //———————————>读取函数的实现 student *Information::Read() { int i=0; p1=p2=( student *)malloc(LEN); head=NULL; ifstream in("data.txt",ios::out); in>>i; if(i==0){cout<<" data.txt 文件中的数据为空,请先输入数据。"<0;i--) { p1=(student *)malloc(LEN); cin>>st.name>>st.id>>st.sex >>st.score[0]>>st.score[1]>>st.score[2]>>st.score[3] >>st.total; strcpy(p1->name,st.name); p1->id=st.id; strcpy(p1->sex,st.sex); p1->score[0]=st.score[0]; p1->score[1]=st.score[1]; p1->score[2]=st.score[2]; p1->score[3]=st.score[3]; p1->total=st.total; if(n==0)head=p1;//如果是输入第一组学生考试信息就将指针p1赋给指针head else p2->next=p1;//否则将p1赋给p2所指结构体的next指针 p2=p1;//将指针p1赋给指针p2 n++; //将n的值加1 //显示读入数据 cout<<" "<name<<"\t" <id<<"\t"<<"\t" <sex<<"\t" <score[0]<<"\t" <score[1]<<"\t" <score[2]<<"\t" <score[3]<<"\t" <total<next=NULL; return (head); } } //------------------------------>主函数. int main(void) { Information person; student *head=NULL; char str[10]; int flag=0; int choice; long int i; head=person.Read(); do{ cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"<>str; if(atoi(str)>7 || atoi(str)<1) cout<<"对不起,请输入1-7这几个数字!!\n"; else { choice=atoi(str); switch(choice) { case 1: head=person.creat(); break; case 2: person.output(head); break; case 3: person.inorder(head); person.average(head); cout<<" 参加考试的学生人数为:"<>str; if(atol(str)>99999999 || atol(str)<1) cout<<"对不起,请输入正确输入!!!\n"; else {i=atol(str); flag=1; } }while(flag==0); flag=0; person.find(head,i); break; case 5: head=person.insert(head); person.output(head); break; case 6: cout<<" 请输入要删除的准考证号(8位):"; do{ cin>>str; if(atol(str)>99999999 || atol(str)<1) cout<<"对不起,请输入正确输入!!!h\n"; else {i=atol(str); flag=1; } }while(flag==0); flag=0; head=person.cancel(head,i); person.output(head); break; case 7: person.save(head); cout<<"文件已保存!可以安全退出!!!"<> 相关内容 • 求毕业 论文 政研论文下载论文大学下载论文大学下载关于长拳的论文浙大论文封面下载 VC“学生信息管理系统”  2010-5-25 • 用VC++做“学生信息管理系统”的登录界面  3  2008-3-19 • 谁能帮我vc++做个学生信息管理系统  5  2008-5-29 • 用VC编写一个学生信息管理系统  2008-7-5 • 谁能提供一下用VC++制作一个学生信息管理系统的代码的啊??  1  2010-7-4   更多关于vc 学生管理系统的问 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 >> 查看同主题问题: 学生信息管理系统 等待您来回答更多 ​ 0回答 谁有《易学C++》这本 关于书的成语关于读书的排比句社区图书漂流公约怎么写关于读书的小报汉书pdf 的电子版帮忙发带407066663@qq.com ​ 0回答 20 Linux windows socket 传输问题 ​ 0回答 C++简单问题,谢谢。 ​ 0回答 苹果电脑YY语音的声卡驱动在哪里? QQ757066637 ​ 0回答 荣成方正房地产公司开发的宝月山庄怎么样 ​ 0回答 c语言中(a)>(b) ? (a):(b)什么意思 ​ 0回答 急!!!在线等!!! ​ 0回答 屡败屡战说明了什么道理 其他回答    共 1 条 #include #include #include struct stud { long num; char name[20]; double score; }; typedef struct stucode { struct stud student ; struct stucode *next; }L; void menu(); void createlist(struct stucode **r); void out(struct stucode *r); void search1(struct stucode *r); void search2(struct stucode *r); void del(struct stucode **r); void insert(struct stucode **r); void sort(struct stucode **r); void main() { char choose; int flag=1; struct stucode *r=NULL; while(flag) { system("cls"); menu(); choose=getchar(); switch(choose) { case '1': createlist(&r); out(r); printf("Testing function 1\nPress any key to continue\n"); getchar(); getchar(); break; case '2': search1(r); printf("Testing function 1\nPress any key to continue\n"); getchar(); getchar(); break; case '3': search2(r); printf("Testing function 1\nPress any key to continue\n"); getchar(); getchar(); break; case '4': del(&r); out(r); printf("Testing function 1\nPress any key to continue\n"); getchar(); getchar(); break; case '5': insert(&r); out(r); printf("Testing function 1\nPress any key to continue\n"); getchar(); getchar(); break; case '6': sort(&r); out(r); printf("Testing function 1\nPress any key to continue\n"); getchar(); getchar(); break; case '7': out(r); printf("Testing function 7\nPress any key to continue\n"); getchar(); getchar(); break; case '0': flag=0; printf("The end.\n"); break; default: printf("\nWrong Selection!(选择错误,请重选!)\n");getchar();getchar(); } } } void createlist(struct stucode **r) { struct stucode *p,*t; long n; char a[20]; double s; if(*r) *r=NULL; printf(" \n请输入:\n 学号(请按学号升序排列) 姓名 分数 (若要结束请输入三个为零)\n"); scanf("%ld%s%lf",&n,a,&s); if(n==0) return; p=(L *)malloc(sizeof(L)); p->student.num=n; strcpy(p->student.name,a); p->student.score=s; p->next=NULL; *r=p; scanf("%ld%s%lf",&n,a,&s); while(n) { t=p; p=(L *)malloc(sizeof(L)); p->student.num=n; strcpy(p->student.name,a); p->student.score=s; p->next=NULL; t->next=p; scanf("%ld%s%lf",&n,a,&s); } } void search1(struct stucode *r) { long x; if(!r) { printf("没有学生信息可查询!\n"); return ; } printf(" 请输入要查询的学生信息的学生学号:\n"); scanf("%ld",&x); while(r&&r->student.num!=x) r=r->next; if(r==NULL) printf("Error! No such student !\n"); else printf("%ld %s %.2lf\n",r->student.num,r->student.name,r->student.score); } void search2(struct stucode *r) { char m[20]; if(!r) { printf("没有学生信息可查询!\n"); return ; } printf(" 请输入要查询的学生信息的学生姓名:\n"); scanf("%s",m); while(r&&strcmp(r->student.name,m)) r=r->next; if(r==NULL) printf("Error! No such student !\n"); else printf("%ld %s %.2lf\n",r->student.num,r->student.name,r->student.score); } void del(struct stucode **r) { long k; struct stucode *p=*r,*t; if(!(*r)) { printf("没有学生信息可删除 !\n"); return ; } printf(" 请输入要删除的学生信息的学生学号:\n"); scanf("%ld",&k); if(p->student.num==k) *r=(*r)->next,free(p); else { while(p->next&&p->next->student.num!=k) p=p->next; if(p->next==NULL) printf("Error! No such student !\n"); else { t=p->next; p->next=p->next->next; free(t); } } } void insert(struct stucode **r) { long n; char a[20]; double s; L *p,*t,*k; printf(" 请输入要插入的学生信息的学生学号 姓名 分数:\n"); scanf("%ld%s%lf",&n,a,&s); p=(L *)malloc(sizeof(L)); p->student.num=n; p->student.score=s; strcpy(p->student.name,a); if(!(*r)) { *r=p; (*r)->next=NULL; return ; } if(p->student.num<(*r)->student.num) p->next=(*r),(*r)=p; else { t=*r; k=t; while(t->next&&t->next->student.num<=p->student.num) t=t->next; p->next=t->next; t->next=p; *r=k; } } void sort(struct stucode **r) { struct stucode *t,*p,*q,*z; if(!r) { printf("没有学生信息可排序!\n"); return ; } if(!(*r)||!(*r)->next) return; t=*r; p=t->next; t->next=NULL; while(p) { q=p->next; if(p->student.score>t->student.score) { p->next=t; t=p; } else { z=t; while(z->next&&z->next->student.score>=p->student.score) z=z->next; p->next=z->next; z->next=p; } p=q; } *r=t; } void out(struct stucode *r) { printf("\n\n"); if(!r) { printf("没有学生信息可输出!\n"); return ; } while(r) { printf("%ld %s %.2lf\n",r->student.num,r->student.name,r->student.score); r=r->next; } printf("\n\n"); } void menu() { printf("\n 学生信息管理系统\n"); printf("\n 菜单\n\n"); printf("\n 1建立链表并显示\n"); printf("\n 2查找某学号的学生信息\n"); printf("\n 3查找某姓名的学生信息\n"); printf("\n 4删除某学号的学生信息\n"); printf("\n 5插入新的学生信息\n"); printf("\n 6按分数降序排列输出\n"); printf("\n 7输出\n"); printf("\n 0退出\n"); printf("\n 请选择您要执行的选项:\n"); }
本文档为【vc学生信息管理系统】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_247295
暂无简介~
格式:doc
大小:168KB
软件:Word
页数:22
分类:互联网
上传时间:2011-03-17
浏览量:39