学生查询网站源码,学生成绩管理系统c源代码

1,学生成绩管理系统c源代码我可以帮你写~不为分,希望你拿去好好看看,其实这个管理系统很简单.还有些问题要问, 不要上网档啥意思?不需要把学生信息存入文件?每次运行都写自己在输入信息? #include #include #include #include #include using namespace std;class studentpublic: student() void write(); void red(); void show(); void sortscore(); int operator<(const student&); int a_bscore(); void deletestudent();private: int id; string name; double score;};vector student;void student::write() student s; char filename[20]; cout<<"请输入文件名:"< cin>>filename; cin.clear(); ofstream out(filename,ios::app); cout<<"请输入学生学号姓名成绩:"< vector::iterator iter; while (cin>>s.id>>s.name>>s.score)iter=student.begin();while (iter!=student.end())if (s.id==iter->id)cout<cout<<"\t"<<" \t"< break; } else iter++; } if (iter==student.end()) { out< student.push_back(s); } } cin.clear(); } void student::show() { vector::const_iterator iter=student.begin(); cout<<"学号\t姓名\t 成绩\t"< while (iter!=student.end()) { cout<<"\t"<<" \t"< iter++; } } void student::red() { student s; char filename[20]; cout<<"请输入文件名:"< cin>>filename; ifstream in(filename); vector::iterator iter; while (in>>s.id>>s.name>>s.score) { iter=student.begin(); while (iter!=student.end()) { if (s.id==iter->id) { break; } else iter++; } if (iter==student.end()) { student.push_back(s); } } cin.clear(); } int student::operator<(const student&s) { return score>s.score?1:0; } void student::sortscore() { sort(student.begin(),student.end()); } int student::a_bscore() { int a,b,low,up,cnt=0; cout<<"请输入要查找的分数段:"< cin>>a>>b; if (a>b) { up=a; low=b; } else { low=a; up=b; } vector::const_iterator iter=student.begin(); while (iter!=student.end()) { if (iter->score>=low&&iter->score<=up) { cout<<"\t"<<" \t"< cnt++; } iter++; } cout<<"分数段"< return cnt; } void student::deletestudent() { student s; cout<<"请输入要删除的学生学号:"< cin>>s.id; vector::iterator iter=student.begin(); while (iter!=student.end()) { if (iter->id==s.id) { break; } else iter++; if (iter!=student.end()) { student.erase(iter); cout<<"ok,"< } else { cout<<"没找到学号为:"< } } } int main() { student s; int choice; cout<<"=-=-=-=-=-=-=-=-=-=-=-=-=-=-欢迎使用学生信息管理系统-=-=-=-=-=-=-=-=-=-=-=-=-=-=" cout<<"1->添加学生信息 2->显示学生信息 3->删除学生信息 "< cout<<" 0-> 退出 "< cout<<"4->从文件添加 5->按成绩排序 6->分数段信息查询"< cin>>choice; if (choice==1) { s.write(); system("cls"); goto begin; } else if (choice==2) { s.show(); system("pause"); system("cls"); goto begin; } else if (choice==3) { s.deletestudent(); system("pause"); system("cls"); goto begin; } else if (choice==4) { s.red(); system("pause"); system("cls"); goto begin; } else if (choice==5) { s.sortscore(); system("pause"); system("cls"); goto begin; } else if (choice==6) { s.a_bscore(); system("pause"); system("cls"); goto begin; } else if (choice==0) { exit(0); } else { cout<<"输入非法?。。?< system("pause"); goto begin; } return 0; } 刚写完的~【学生查询网站源码,学生成绩管理系统c源代码】
2,学生信息管理系统最简单源代码一.需求分析用动态链表储管理姓名、电话、住址、身份证等信息和具备添加、删除等编辑功能可以通过身份证号码识别性别,省份,年龄可以统计总人数 , 男生人数,女生人数 , 同一年龄段人数可以通过姓名,身份证号查询与修改数据具备较美观的界面与汉字提示具备保存信息至文件 , 及从文件中读取信息的功能用动态链表来储存数据,便于管理二.概要设计流程图添加信息声明一个结构体来储存数据,并通过声明指针来动态添加信息显示信息声明一个结构体指针 , 让指针等于头指针,并遍历所有节点,打印每个节点的信息查询信息1.获取用户的选择确定 用姓名查找或是身份证号查找2.遍历所有节点,找到与用户输入相和的节点3.打印该节点的信息修改信息1.获取用户的选择确定 用姓名查找或是用身份证号查找并修改2.遍历所有节点 , 找到与用户输入相和的节点3.开始修改该节点的姓名,身份证号 , 手机号删除信息1.获取用户的选择确定 用姓名查找并删除或是用身份证号查找并删除,及全部删除2.遍历所有节点 , 找到与用户输入相和的节点的上一个节点的地址3.将这个节点的next储存为下下个节点的地址4.删除中间的节点数据分析1.遍历所有节点2.依次辨别性别 , 年龄段3.在储存总人数,男生人数,女生人数,年龄段的数据上添加人数保存信息至文件1.遍历每个节点2.将每个节点的信息储存到文件中3.每储存一个count便加一4.打印储存数据的个数从文件中读取数据1.将文件中的数据依次添加到新的节点上退出程序将菜单的while(running)循环,running=0三.详细设计信息添加struct IdCardchar num[20];char phone[11];int sex;char city[20];char name[20];long age;struct IdCard *next;};struct IdCard *head=NULL;//声明一个头节点作为全局变量 , 且使他为空动态生成节点,并往节点中添加信息,生成动态链表while(strcmp(pid1->num,str)!=0)n++;if(n==1) head=pid1;else pid2->next=pid1;pid2=pid1;pid1=(struct IdCard*)malloc(sizeof(struct IdCard));printf("请输入身份证号(按0退出):");char str[]="0";//用来辨别scanf("%s",pid1->num);if(strcmp(pid1->num,str)==0) break;在此处通过身份证号计算相应的年龄,性别,将这些信息添加到该节点上 。效果图如下菜单样式通过printf打印选项在while中循环 , 使菜单一直刷新存在在while中的最后加system(“pause”)使每个键盘信息能被显示出来效果图如下:显示信息struct IdCard *pid;//遍历节点pid=head;通过遍历节点打印出所有节点的信息效果图如下:查询信息int num;printf("按1,身份证号查询\n按2,姓名查询:\n");获取用户的选择声明字符串变量来储存用户输入的姓名或身份证号遍历所有节点,找到与用户相符合的那个节点 , 并打印struct IdCard *pid;pid=head;while(pid)if(strcmp(pid->num,num)==0)printf("------------------------------显示所有信息---------------------------------------\n"); printf("身份证号姓名性别省份手机号年龄\n");printf("%18s ",pid->num);printf("%-16s",pid->name);printf("%-13s",pid->sex==1?"男":"女");printf("%-14s",pid->city);printf("%11s",pid->phone);printf("%d\n",pid->age);printf("---------------------------------------------------------------------------------\n");}pid=pid->next;}效果图如下:修改信息获取用户的选择ystem("cls");char name[20];printf("请输入要修改的名字(20个字节):\n");while(1!=scanf("%s",name))printf("你的输入有误,请重新输入(20个字节):");fflush(stdin);选择相应的修改方式遍历节点选到与用户输入相符的节点,并修改struct IdCard *pid,*ptmp;pid=head;while(pid)if(strcmp(pid->name,name)==0)printf("请输入你要重写的身份证号:\n");while(1!=scanf("%s",pid->num)||strlen(pid->num)!=18)printf("你的输入有误,请重新输入(18位):");fflush(stdin);}效果图如下:保存信息至文件以只写的二进制方式打开一个文件FILE *pf = fopen("FILENAME", "wb");遍历节点struct IdCard *pid = head;if(!pf)printf("打开待写入的文件失败!\n");return;}while(pid)fwrite(pid, 1, sizeof(struct IdCard), pf);//把每位学生信息写入文件i++;pid = pid->next;}fclose(pf); printf("\t\t\t成功写入%d信息",i);将每个节点写入文件中 , 用frwite函数声明一个变量来计算写入的信息数效果图如下:从文件中读取信息以只读的二进制方式打开文件夹FILE *pf;struct IdCard *pid;if((pf = fopen("FILENAME", "rb")) == NULL)printf("文件还没有创建,请手工输入学生信息并保存吧!\n");return;}申请新的空间将地址赋给节点struct IdCard *pid1,*pid2;pid1=pid2=(struct IdCard*)malloc(sizeof(struct IdCard));fread(pid1,1,sizeof(struct IdCard),pf);while(!feof(pf))i++;if(head==NULL)head=pid1;}elsepid2->next=pid1;}pid2=pid1;pid1 = (struct IdCard*)malloc(sizeof(struct IdCard));fread(pid1,1, sizeof(struct IdCard), pf);} fclose(pf);printf("文件读取完毕!新增学生信息%d条 。\n",i);将文件信息写入节点中将节点添加进动态链表中声明一个变量来记录读出信息数量效果图如下:数据分析遍历每个节点int ManCount=0,WomanCount=0,age1Count=0,age2Count=0,count=0;struct IdCard *pi;pi=head;while(pi)count++;if(pi->sex==1)ManCount++;}elseWomanCount++;}if(pi->age>10&&pi->age<20)age1Count++;if(pi->age>20&&pi->age<40)age2Count++;pi=pi->next;}printf("\n");printf("总共有%d个身份证\n男的占%d个\n女的占%d个\n年龄段在10到20岁之间的有%d个\n年龄段在20到40岁之间的有%d个\n",count,ManCount,WomanCount,age1Count,age2Count);辨别每个节点的性别,年龄段在相应的变量上加减于是统计出了总信息数量,男生数量,女生数量,各年龄段数量效果图如下:四.测试结果程序开始运行回车键后显示菜单添加信息当身份证号输入的位数不够18位时,会报错 , 当手机号不够11位时,会报错重新输入查询信息删除一个信息删除所有信息修改信息保存信息至文件从文件中读取信息显示所有信息数据分析五.用户使用说明信息添加:可以输入相应的身证号,名字与手机号 。当身份证号与手机号的位数输入错误时,会有相应的提示,此时你可以重新输入 。在输入信息结束时,可以按0保存信息至文件如果想要在下一次打开此程序时 , 还能看到相应的信息 , 一定要记得保存信息至文件,但此次保存文件会覆盖上一次的信息从文件中读取信息从文件中读取的信息会添加到你新写的信息后面,当显示所有信息时,会以链表形式逐个打印出来查询信息当你输入的信息查找不到时,此时不会打印任何信息,可按任意键回到菜单 。同样输入手机号和身份证号会检查你的位数对不对,不对的话,将提示你重新输入修改信息当你输入相应的身份证号或名字时,会让你把这个人的信息全部输入一次删除所有信息该选项将会删除你所有的信息 , 谨慎!删除一个信息可以选择你想删除的身份证号或名字,删除掉其中一个信息,不会影响其他信息数据分析会统计出总信息数量,男生数量,女生数量,各年龄段数量退出程序按0会退出程序,此次使用身份证信息管理系统结束Hu118391徊 c语言课程设计希望我的回答,你能喜欢

    推荐阅读