|
1楼 #include <string.h> #include <fstream.h> struct student { char num[10]; char name[20]; int age; int score; struct student *next; }; class grade { private : struct student * head,* last; public : void init(); void insert(); int delete(); int select(); int modify(); int display(); int total(); void savefile(); void quit(); }; void grade::init() { printf("************************************主菜单************************************\n"); printf("\t1输入学生资料\t\t\t\t\t2删除学生资料\n"); printf("\t3查询学生资料\t\t\t\t\t4修改学生资料\n"); printf("\t5显示学生资料\t\t\t\t\t6统计学生成绩\n"); printf("\t7保存学生资料\t\t\t\t\t0退出系统\n"); printf("******************************************************************************\n"); head=last=NULL; } void grade::insert() { struct student * p; p=(struct student *)malloc(sizeof(struct student)); cout<<"please insert num,name,age,score"<<endl; cin>>p->num>>p->name>>p->age>>p->score; if (head==NULL) {head=p;last=p;last->next=NULL;} else { last->next=p; last=p; last->next=NULL; } } int grade::delete() { char dnum;/* 要删除的学号*/ struct student * p,p1; cout<<"请你输入要删除的学号:"<<endl; cin>>dnum; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} if (head->next=NULL && strcpy(head->num,dnum)==0)/* 只有一个记录且是要删除的数据*/ {head=NULL;last=NULL;return 0;} p=head; while(p->next!=NULL) { p1=p->next; if (strcpy(p->num,dnum)==0 && p1->next==NULL )/* 数据在到数第二的位置*/ {p->next=last;cout<<"one student has been deleted"<<endl;return 0;} else if (p1==NULL && strcpy(p1->num,dnum)==0)/* 数据在到数第一的位置*/ {p->next=NULL;last=p;cout<<"one student has been deleted"<<endl;return 0;} else if (strcpy(p->num,dnum)==0 && p1->next!=NULL ) {p->next=p1->next;p=p1;/*p=p1;等一下次执行p=p->next;实际p已经指到p1->next了*/ cout<<"one student has been deleted"<<endl;return 0;} p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::select() { char snum;/* 要查询的学号*/ struct student * p; cout<<"请你输入要查询的学号:"<<endl; cin>>snum; p=head; while(p!=NULL) { if (strcpy(p->num,snum)==0) { cout<<"num:"<<p->num<<"\nname"<<p->name<<"\nage"<<p->age<<"\nscore"<<p->score<<endl; return 0; } p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::modify() { char mnum;/* 要修改的学号*/ struct student *p; cout<<"请你输入要修改的学号:"<<endl; cin>>mnum; p=head; while(p!=NULL) { if (strcpy(p->num,mnum)==0) { cout<<"please insert the new name,age,score"<<endl; cin>>p->name>>p->age>>p->score; cout<<"one student has been modify"<<endl; return 0; } p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::display() { struct student *p; p=head; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} while(p!=NULL) { cout<<"num:"<<p->num<<"\nname"<<p->name<<"\nage"<<p->age<<"\nscore"<<p->score<<endl; p=p->next; } return 0; } int grade::total() { int max,jg_num=0; struct student *p; p=head; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} max=p->score; while(p!=NULL) { if (p->score>max) max=p->score; if (p->score<60) jg++; p=p->next; } cout<<"the high score:"<<max<<endl; cout<<"不及格学生人数:"<<jg<<endl; return 0; } void savefile() { struct student * p; ifstream input; input.open("student"); p=head; while(p!=head) { input>>p->num>>p->name>>p->age>>p->score; p=p->next; } cout<<"the file save over"<<endl; } int main() { int choice; grade Grage; Grade.init(); while(1) { cin>>choice; switch(choice) { case 1:void Grade.insert(); break; case 2:int Grade.delete(); break; case 3:int Grade.select(); break; case 4:int Grade.modify(); break; case 5:int Grade.display();break; case 6:int Grade.total(); break; case 7:int Grade.savefile();break; case 0: return 0; } } return 0; } |
|
|
|
| 220.169.49.* |
6楼 |
|
|
|
16楼 #include <string.h> #include <fstream> using namespace std; struct student { char num[10]; char name[20]; int age; int score; struct student *next; }; class grade { private : struct student * head; public : void menu(); void init(); void insert(); int delete_f(); int select(); int modify(); int display(); int total(); void savefile(); void quit(); }; void grade::init() { cout<<"************************************主菜单************************************\n"; cout<<"\t1输入学生资料\t\t\t\t\t2删除学生资料\n"; cout<<"\t3查询学生资料\t\t\t\t\t4修改学生资料\n"; cout<<"\t5显示学生资料\t\t\t\t\t6统计学生成绩\n"; cout<<"\t7保存学生资料\t\t\t\t\t0退出系统\n"; cout<<"******************************************************************************\n"; head=NULL; } void grade::menu() { cout<<"************************************主菜单************************************\n"; cout<<"\t1输入学生资料\t\t\t\t\t2删除学生资料\n"; cout<<"\t3查询学生资料\t\t\t\t\t4修改学生资料\n"; cout<<"\t5显示学生资料\t\t\t\t\t6统计学生成绩\n"; cout<<"\t7保存学生资料\t\t\t\t\t0退出系统\n"; cout<<"******************************************************************************\n"; } void grade::insert() { struct student * p,*p1; p=(struct student *)malloc(sizeof(struct student)); cout<<"please insert num,name,age,score"<<endl; cin>>p->num>>p->name>>p->age>>p->score; if (head==NULL) {head=p;head->next=NULL;} else { p1=head; while(p1->next!=NULL) p1=p1->next; p1->next=p; p->next=NULL; } } int grade::delete_f() { char dnum[10];/* 要删除的学号*/ struct student *p,*p1; cout<<"请你输入要删除的学号:"<<endl; cin>>dnum; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} if (head->next==NULL && strcmp(dnum,head->num)==0) {head=NULL;cout<<"one student has been deleted"<<endl;return 0;} /* 只有一个记录且是要删除的数据*/ p=head; while (p->next!=NULL) { p1=p->next; if (strcmp(dnum,head->num)==0) {head=head->next;cout<<"one student has been deleted"<<endl;return 0;} /* 要删除的数据在文件头*/ if (strcmp(dnum,p1->num)==0) {p->next=p1->next;cout<<"one student has been deleted"<<endl;return 0;} p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::select() { char snum[10];/* 要查询的学号*/ struct student * p; cout<<"请你输入要查询的学号:"<<endl; cin>>snum; p=head; while(p!=NULL) { if (strcmp(p->num,snum)==0) { cout<<"num: "<<p->num<<"\nname: "<<p->name<<"\nage: "<<p->age<<"\nscore: "<<p->score<<endl; return 0; } p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::modify() { char mnum[10];/* 要修改的学号*/ struct student *p; cout<<"请你输入要修改的学号:"<<endl; cin>>mnum; p=head; while(p!=NULL) { if (strcmp(p->num,mnum)==0) { cout<<"please insert the new name,age,score"<<endl; cin>>p->name>>p->age>>p->score; cout<<"one student has been modified"<<endl; return 0; } p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::display() { struct student *p; p=head; if (head==NULL) {cout<<"no student can be displayed"<<endl;return 0;} while(p!=NULL) { cout<<"num: "<<p->num<<"\nname: "<<p->name<<"\nage: "<<p->age<<"\nscore: "<<p->score<<endl; p=p->next; cout<<endl; } return 0; } int grade::total() { int max,jg=0; struct student *p; p=head; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} max=p->score; while(p!=NULL) { if (p->score>max) max=p->score; if (p->score<60) jg++; p=p->next; } cout<<"the high score:"<<max<<endl; cout<<"不及格学生人数:"<<jg<<endl; return 0; } void grade::savefile() { struct student * p; ifstream input; input.open("student"); p=head; while(p!=head) { input>>p->num>>p->name>>p->age>>p->score; p=p->next; } cout<<"the file save over"<<endl; } int main() { int choice; grade Grade; Grade.init(); while(1) { cin>>choice; switch(choice) { case 1: Grade.insert(); break; case 2: Grade.delete_f(); break; case 3: Grade.select(); break; case 4: Grade.modify(); break; case 5: Grade.display();break; case 6: Grade.total(); break; case 7: Grade.savefile();break; case 0: return 0; } Grade.menu(); } return 0; } |
|
|
|
|
18楼 #include <iostream.h> #include <string.h> #include <fstream.h> struct student { char num[10]; char name[20]; int age; int score; struct student *next; }; class grade { private : struct student * head,* last; public : void init(); void insert(); int delet(); int select(); int modify(); int display(); int total(); void savefile(); void quit(); }; void grade::init() { cout<<"************************************主菜单************************************\n"<<endl; cout<<"\t1输入学生资料\t\t\t\t\t2删除学生资料\n"<<endl; cout<<"\t3查询学生资料\t\t\t\t\t4修改学生资料\n"<<endl; cout<<"\t5显示学生资料\t\t\t\t\t6统计学生成绩\n"<<endl; cout<<"\t7保存学生资料\t\t\t\t\t0退出系统\n"<<endl; cout<<"******************************************************************************\n"<<endl; head=last=NULL; } void grade::insert() { struct student * p; //p=(struct student *)malloc(sizeof(struct student)); p = new student; cout<<"please insert num,name,age,score"<<endl; cin>>p->num>>p->name>>p->age>>p->score; if (head==NULL) {head=p;last=p;last->next=NULL;} else { last->next=p; last=p; last->next=NULL; } } int grade::delet() { char* dnum ;/* 要删除的学号*/ struct student * p, *p1; cout<<"请你输入要删除的学号:"<<endl; cin>>dnum; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} if (head->next=NULL && strcpy(head->num,dnum)==0)/* 只有一个记录且是要删除的数据*/ {head=NULL;last=NULL;return 0;} p=head; while(p->next!=NULL) { p1=p->next; if (strcpy(p->num,dnum)==0 && p1->next==NULL )/* 数据在到数第二的位置*/ {p->next=last;cout<<"one student has been deleted"<<endl;return 0;} else if (p1==NULL && strcpy(p1->num,dnum)==0)/* 数据在到数第一的位置*/ {p->next=NULL;last=p;cout<<"one student has been deleted"<<endl;return 0;} else if (strcpy(p->num,dnum)==0 && p1->next!=NULL ) {p->next=p1->next;p=p1;/*p=p1;等一下次执行p=p->next;实际p已经指到p1->next了*/ cout<<"one student has been deleted"<<endl;return 0;} p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::select() { char* snum;/* 要查询的学号*/ struct student * p; cout<<"请你输入要查询的学号:"<<endl; cin>>snum; p=head; while(p!=NULL) { if (strcpy(p->num,snum)==0) { cout<<"num:"<<p->num<<"\nname"<<p->name<<"\nage"<<p->age<<"\nscore"<<p->score<<endl; return 0; } p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::modify() { char* mnum;/* 要修改的学号*/ struct student *p; cout<<"请你输入要修改的学号:"<<endl; cin>>mnum; p=head; while(p!=NULL) { if (strcpy(p->num,mnum)==0) { cout<<"please insert the new name,age,score"<<endl; cin>>p->name>>p->age>>p->score; cout<<"one student has been modify"<<endl; return 0; } p=p->next; } cout<<"no student can be found"<<endl;return 0; } int grade::display() { struct student *p; p=head; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} while(p!=NULL) { cout<<"num:"<<p->num<<"\nname"<<p->name<<"\nage"<<p->age<<"\nscore"<<p->score<<endl; p=p->next; } return 0; } int grade::total() { int max,jg_num=0; struct student *p; p=head; if (head==NULL) {cout<<"no student can be found"<<endl;return 0;} max=p->score; while(p!=NULL) { if (p->score>max) max=p->score; if (p->score<60) jg_num++; p=p->next; } cout<<"the high score:"<<max<<endl; cout<<"不及格学生人数:"<<jg_num<<endl; return 0; } void grade::savefile() { struct student * p; ifstream input; input.open("student"); p=head; while(p!=head) { input>>p->num>>p->name>>p->age>>p->score; p=p->next; } cout<<"the file save over"<<endl; } int main() { int choice; grade Grade; Grade.init(); while(1) { cin>>choice; switch(choice) { case 1: Grade.insert(); break; case 2: Grade.delet(); break; case 3: Grade.select(); break; case 4: Grade.modify(); break; case 5: Grade.display(); break; case 6:Grade.total(); break; case 7: Grade.savefile(); break; case 0: return 0; } } return 0; } |
|
|
|
|
20楼 last,head两个指针,结果发现很难用。所以现在只用head一个。 还有strcpy(p->num,mnum)==0)这个记错了,应该是strcmp(),这个才是比较两个字符的函数。 还有 char mnum;改为了char mnum[10]; 主要是这几个了。 |
|
|
|
|
22楼 还有你把char mnum;改为char * mnum行吗,我也不知道. 你还是仔细看一下我的程序了,如果还有问题,加我QQ吧 303890400 |
|
|
|
| 218.7.49.* |
23楼 我学的时候走要累死了 |
|
|
| 211.69.2.* |
24楼 后面的还不错 |
|
|
|
25楼 运动会成绩管理 成绩录入 成绩查询 按项目排名 按系排名 要求 (1) 成绩数据应包括系名、姓名、学号、项目名称、成绩等并保存到某文件中 (2) 采用模块化程序设计方法,主函数用菜单形式调用各功能函数,程序可读性强,界面设计友好,输出形式美观 需求分析 程序框图(总体框图和个功能模块框图,使用结构化流程图或N-S流程图) 的程序啊 谢谢了 我后天就要交了是课程设计 我原来就挂了好多了不能再挂了希望打击啊帮一下 真的感谢大家了 |
|
|
|
| 218.58.61.* |
26楼 |
|
|
| 218.25.56.* |
27楼 |
|
|
| 218.57.64.* |
28楼 我是初学者希望好心的人帮我尽快的作出来 谢谢!!!! |
|
|
| 218.57.64.* |
29楼 |
|
|
|
30楼 |
|
|
|
| 61.132.1.* |
31楼 |
|
|
