c语言学生管理系统源代码
学生管理系统c语言源代码
int main()
{
initLinkTable(&head);//初始化表头
readStu();//读入源文件
while (1)
{
menu();
system("cls");
}
}
void initLinkTable(studentLinkPoint *p)
int sum(studentLinkPoint);//求和
void avg(studentLinkPoint);//求平均分
void disAvgSum(studentLinkPoint);//显示总分和平均分
char *inputNumber();//专门用来输入一个学生的学号,返回该字符串的指针
char name[20];
char number[18];
int i;
if(temp==0)
{
error("input");
return 0;
}
else
{
temp->student=(studentPint)malloc(sizeof(studentNod));
break;
case 0:
del(head,end);
break;
}
if(c==0)
exit(1);
}
void del(studentLinkPoint p,studentLinkPoint End)
{
studentLinkPoint q;
if(end==head)
printf(" %3.1f %3.1f\n",p->student->sum,p->student->avg);
C语言课程设计——学生管理系统源代码
C语言课程设计——学生管理系统源代码#include<stdio.h>#include<stdlib.h>#include<string.h>#include<conio.h>#define MY1 printf("学号\t姓名\t性别\t年龄\t生日")#define MY2 printf("\n%d %6s %4s\t%2d %8d%2d%2d \n",s[i].num,s[i].name,s[i].sex,s[i].age,s[i].a.year,s[i].a.month,s[i].a.day)#define MY3 printf("家庭住址联系方式高数英语大物总成绩")#define MY4 printf("\n%4s %4s %2d %2d %2d %2d\n",s[i].address,s[i].tel,s[i].c.gao,s[i].c.ying,s[i].c.wu,s[i].c.total)#define MAX 30int i;int sum;/*时间结构体类型*/struct date{int year;int month;int day;}a;/*学生成绩结构体类型*/struct score{int gao;int ying;int wu;int total;}c;/*学生信息结构体类型*/struct s_message{int num;char name[20];char sex[5];int age;struct date a;char address[50];char tel [11];struct score c;}s[MAX];/*保存学生信息模块*/void save_message(int sum){int i;FILE*fp;if((fp=fopen("D:\\s.txt","wb"))==NULL){printf("reading file is wrong!\n");return;}for (i=0;i<sum;i++){if(fwrite(&s[i],sizeof(struct s_message),1,fp)!=1)printf("writing file is wrong!\n");}fclose(fp);}/*读取学生信息模块*/int read_message(){FILE *fp;int i=0;if((fp=fopen("D:\\s.txt","rb"))==NULL){printf("\n\n***********暂时无任何库存信息,按回车键进入主菜单选择基本信息的录入!***********\n");return 0 ;}while(feof(fp)==0){if(fread(&s[i],sizeof(struct s_message),1,fp)!=1) break;i++;}fclose(fp);return(i);}/*输入学生信息模块*/putin_message(){system("cls");int i=0,m=0;printf("\n\n***********输入学生信息****************\n\n");printf("输入要输入的学生的个数(m<MAX)\n");scanf("%d",&m);for(i=sum;i<sum+m;i++){ printf("\n\n第%d个学生的信息\n",i+1);printf("\n 学生学号:");scanf("%d",&s[i].num);if(s[i].num==0) break;printf("\n 学生姓名:");scanf("%s",s[i].name);printf("\n 学生性别:");scanf("%s",s[i].sex);printf("\n 学生年龄:");scanf("%d",&s[i].age);printf("\n 学生生日:");scanf("%d%d%d",&s[i].a.year,&s[i].a.month,&s[i].a.day);printf("\n 家庭住址:");scanf("%s",s[i].address);printf("\n 联系方式:");scanf("%s",s[i].tel);printf("\n 高数--英语--大物(成绩0-100):");scanf("%d%d%d",&s[i].c.gao,&s[i].c.ying,&s[i].c.wu);s[i].c.total=s[i].c.gao+s[i].c.ying+s[i].c.wu;flushall();}printf("\n***********************学生信息输入完毕**********************\n");sum+=m;printf("\n 按回车键返回主菜单!");getch();return 0;}/*输出学生信息模块*/void putout_message(){system("cls");int i=0;printf("\n*****************************学生信息表**********************\n\n");for(i=0;i<sum;i++){MY1;MY2;MY3;MY4;printf("\n\n");}printf("按回车键返回主菜单!");getch();}/*添加学生信息*/insert_message(){system("cls");int i=sum,flag=0;char choice;printf("\n\n**********添加一个学生信息***********\n");do{printf("\n 学生学号:");scanf("%d",&s[i].num);if(s[i].num==0) break;printf("\n 学生姓名:");fflush(stdin);scanf("%s",s[i].name);printf("\n 学生性别:");scanf("%s",s[i].sex);printf("\n 学生年龄:");scanf("%d",&s[i].age);printf("\n 学生生日:");scanf("%d %d %d",&s[i].a.year,&s[i].a.month,&s[i].a.day);printf("\n 学生家庭住址:");scanf("%s",s[i].address);printf("\n 联系方式:");scanf("%s",s[i].tel);printf("\n 高数--英语--大物(成绩0-100):");scanf("%d%d%d",&s[i].c.gao,&s[i].c.ying,&s[i].c.wu);s[i].c.total=s[i].c.gao+s[i].c.ying+s[i].c.wu;sum++;printf("\n 要继续吗?(Y/N)");choice=getch();if(choice=='y'||choice=='Y'){printf("\n 继续!\n");i++;flag=1;}else flag=0;}while(flag==1);printf(" 按回车键返回主菜单!");getch();return 0;}/*修改学生信息*/revise_message(){system("cls");int i=0,choice1;int revise_num,flag=0;int r=0;char choice2;printf("\n 输入要修改的学生的学号:");scanf("%d",&revise_num);for(i=0;i<sum;i++){if(revise_num==s[i].num)r=1;}if(r==0||revise_num==0)printf("没有该学生的相关信息");do{for(i=0;i<sum;i++){if(s[i].num==revise_num){printf("\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 8.高数--英语--大物--总成绩\n");printf("请选择:");scanf("%d",&choice1);switch(choice1){case 1: printf("\n 输入修改后的学生学号:");scanf("%d",&s[i].num);break;case 2: printf("\n 输入修改后的学生姓名:");scanf("%s",s[i].name);break;case 3: printf("\n 输入修改后的学生性别:");scanf("%s",s[i].sex);break;case 4: printf("\n 输入修改后的学生年龄:");scanf("%d",&s[i].age);break;case 5: printf("\n 输入修改后的学生生日:");scanf("%d%d%d",&s[i].a.year,&s[i].a.month,&s[i].a.day);break;case 6: printf("\n 输入修改后的学生家庭住址: ");scanf("%s",s[i].address);break;case 7: printf("\n 输入修改后的联系方式:");scanf("%s",s[i].tel);break;case 8: printf("\n 输入修改后的高数--英语--大物(成绩0-100):");scanf("%d%d%d",&s[i].c.gao,&s[i].c.ying,&s[i].c.wu);break;}}}printf("\n 要继续吗?(Y/N)");choice2=getch();if(choice2=='y'||choice2=='Y'){printf("\n 继续!\n");flag=1;}else flag=0;}while(flag==1);printf(" 按回车键返回主菜单!");getch();return 0;}/*更新学生信息模块*/renew_message(){system("cls");int choice;do{printf("\n\n\n*****************更新学生信息*******************\n\n");printf(" 1.添加学生信息\n\n");printf(" 2.修改学生信息\n\n");printf(" 0.返回主菜单\n\n");printf(" choice(0-2)");scanf("%d",&choice);switch(choice){case 1:insert_message();break;case 2:revise_message();break;case 0:break;}}while(choice!=0);return 0;}/*按学号查询*/int inquire_num(){system("cls");int i=0,j,r=0;printf("\n 输入要查询的学生的学号:");scanf("%d",&j);for(i=0;i<sum;i++){if(j==s[i].num)r=1;}if(r==0||j==0)printf("没有该学生的相关信息");for(i=0;i<sum;i++)if(j==s[i].num){printf("\n **********学生信息**********\n");MY1;MY2;MY3;MY4;}getch();return 0;}/*按姓名查询*/int inquire_name(){system("cls");int i=0,r=0;char inquire_name[20];printf("\n 输入要查询的学生的姓名:");scanf("%s",inquire_name);for(i=0;i<sum;i++){if(strcmp(s[i].name,inquire_name)==0)r=1;}if(r==0)printf("无该学生信息\n");for(i=0;i<sum;i++)if(strcmp(s[i].name,inquire_name)==0){printf("\n **********学生信息**********\n");MY1;MY2;MY3;MY4;}getch();return 0;}/*查询高数成绩及格的学生*/ int inquire_gao(){system("cls");int i=0,j=0;int x=60;printf("\n ***高数成绩及格的学生的信息***\n");for(i=0;i<sum;i++)if(s[i].c.gao>=x){MY1;MY2;MY3;MY4;j++;}if(j==0)printf("无高数成绩及格的学生\n");getch();return 0;}/*查询英语成绩及格的学生*/ int inquire_ying(){system("cls");int i=0,j=0;int x=60;printf("\n ***英语成绩及格的学生的信息***\n");for(i=0;i<sum;i++)if(s[i].c.ying>=x){MY1;MY2;MY3;MY4;j++;}if(j==0)printf("无英语成绩及格的学生\n");getch();return 0;}/*查询大学物理成绩及格的学生*/ int inquire_wu(){system("cls");int i=0,j=0;int x=60;printf("\n ***大学物理成绩及格的学生的信息***\n");for(i=0;i<sum;i++)if(s[i].c.wu>=x){MY1;MY2;MY3;MY4;j++;}if(j==0)printf("无物理成绩及格的学生\n");getch();return 0;}/*查询各门成绩及格的学生*/int inquire_jige(){system("cls");int choice;do{printf("\n\n********查询学生信息*********\n\n");printf(" 1.查询高数成绩及格的学生\n\n");printf(" 2.查询英语成绩及格的学生\n\n");printf(" 3.查询大学物理成绩及格的学生\n\n");printf(" 0.返回主菜单\n\n");printf(" choice(0-3)\n\n");scanf("%d",&choice);switch(choice){case 1: inquire_gao();break;case 2: inquire_ying();break;case 3: inquire_wu();break;case 0: break;}}while(choice!=0);getch();return 0;}/*查询学生信息模块*/inquire_message(){system("cls");int choice;do{printf("\n\n\n********查询学生信息*********\n\n");printf(" 1.按学号查询\n\n");printf(" 2.按姓名查询\n\n");printf(" 3.查询各门成绩及格的学生\n\n");printf(" 0.返回主菜单\n\n");printf(" choice(0-3)\n\n");scanf("%d",&choice);switch(choice){case 1: inquire_num();break;case 2: inquire_name();break;case 3: inquire_jige();break;case 0: break;}}while(choice!=0);getch();return 0;}/*按学号排名*/int rank_num(){ system("cls");int i=0,j;struct s_message t;for(i=0;i<sum-1;i++){for(j=i+1;j<sum;j++){if(s[i].num>s[j].num){t=s[j];s[j]=s[i];s[i]=t;}}}printf(" 从学号小到大排列:\n");for(i=0;i<sum;i++){MY1;MY2;MY3;MY4;}getch();return 0;}/*按成绩排名*/int rank_score(){ system("cls");int i=0,j;struct s_message t;for(i=0;i<sum-1;i++){for(j=i+1;j<sum;j++){if(s[i].c.total<s[j].c.total){t=s[j];s[j]=s[i];s[i]=t;}}}printf(" 从成绩高到低排列:\n");for(i=0;i<sum;i++){MY1;MY2;MY3;MY4;}getch();return 0;}/*学生排名信息模块*/int rank_message(){ system("cls");int choice;do{printf("\n\n\n***********排名信息************\n\n");printf(" 1.按学号排名\n\n");printf(" 2.按成绩排名\n\n");printf(" 0.返回主菜单\n\n");printf(" choice(0-2)");scanf("%d",&choice);switch(choice){case 1:rank_num();break;case 2:rank_score();break;case 0:break;}}while(choice!=0);return 0;}/*统计男女学生的信息*/int count_nn(){system("cls");int i=0,j=0;char k[5];printf("\n 输入要统计的学生的性别:");scanf("%s",k);printf("\n********** %s的学生的信息**********\n",k);for(i=0;i<sum;i++){if(strcmp(s[i].sex,k)==0){MY1;MY2;MY3;MY4;j++;}}printf("统计%s的人数是:%d",k,j);getch();return 0;}/*按学号删除*/int del_num(){system("cls");int i=0,m=0,k=0,flag;char choice;char de_num;do{printf("\n 输入要删除的学生的学号:");scanf("%d",&de_num);for(i=0;i<sum;i++){if(s[i].num!=de_num);else break;}for(i=0;i<sum;i++){if(s[i].num==de_num){m=i;for(i=m+1;i<sum;i++)s[i-1]=s[i];}}sum--;printf("\n 此学生的信息已被删除**********\n");printf("\n 要继续删除吗?(Y/N)");choice=getch();if(choice=='y'||choice=='Y'){printf("\n 继续!\n");k++;flag=1;}else flag=0;}while(flag==1);printf(" 按任意键返回主菜单!");getch();return 0;}/*按姓名删除*/int del_name(){system("cls");int i=0,m=0,k=0,flag;char choice;char de_name[20];do{printf("\n 输入要删除的学生的姓名:");scanf("%s",&de_name);for(i=0;i<sum;i++){if(strcmp(s[i].name,de_name)!=0);else break;}for(i=0;i<sum;i++){if(strcmp(s[i].name,de_name)==0){m=i;for(i=m+1;i<sum;i++)s[i-1]=s[i];}}sum=sum-1;printf("\n 此学生的信息已被删除**********\n");printf("\n 要继续删除吗?(Y/N)");choice=getch();if(choice=='y'||choice=='Y'){printf("\n 继续!\n");k++;flag=1;}else flag=0;}while(flag==1);printf(" 按任意键返回主菜单!");getch();return 0;}/*删除学生信息模块*/del_message(){system("cls");int choice;do{printf("\n\n\n*****删除学生信息*****\n\n");printf(" 1.按学号删除\n\n");printf(" 2.按姓名删除\n\n");printf(" 0.返回主菜单\n\n");printf(" choice(0-2)");scanf("%d",&choice);switch(choice){case 1:del_num();break;case 2:del_name();break;case 0:break;}}while(choice!=0);getchar();return 0;}/*主函数*/void main(){system("cls");int choice,m;sum=read_message();char a[4]="110",b[4];printf("\n\n\n**********************************请您输入密码**********************************\n");printf("密码:");for(m=0;m<3;m++){ b[m]=getch();printf("*");}b[3]='\0';getch();if(strcmp(a,b)==0){do{printf("\n\n************************************************************************** ******\n");printf("\n\n************密码输入成功欢迎您进入学生信息管理系统******************************\n\n");printf("************************************************************************* *******\n");printf(" 1.录入学生信息\n\n");printf(" 2.输出学生信息\n\n");printf(" 3.更新学生信息\n\n");printf(" 4.查询学生信息\n\n");printf(" 5.学生排名信息\n\n");printf(" 6.统计学生信息\n\n");printf(" 7.删除学生信息\n\n");printf(" 0.退出系统\n\n");printf(" 请选择(0-7):");scanf("%d",&choice);switch(choice){case 1: putin_message();save_message(sum);break;case 2: putout_message();break;case 3: renew_message();break;case 4: inquire_message();break;case 5: rank_message();break;case 6: count_nn();break;case 7: del_message();break;case 0: break;}}while(choice!=0);save_message(sum);printf("学籍信息被保存!--(s.txt)\n");}}。
(完整word版)学生信息管理系统c语言版源代码
#include <stdio.h>#include <string.h> #include <stdlib.h> #include <conio.h> #define N 1000 typedef struct student {int number;char name[20];int grade;int gaoshu;int yingyu;int jisuanji;int sum;}STUDENT; STUDENT student[N]; int shuliang=0;void menu();void fhzjm(){char biaozhi[20]; printf("\n");printf("还需要操作么?如果需要操作请输入:yes,否则请输入:no\n");scanf("%s",biaozhi);if(strcmp(biaozhi,"yes")==0){menu();}else if(strcmp(biaozhi,"no")==0)exit(0);else{printf("请输入正确的字符,谢谢!\n");fhzjm();}}void DengJi(){int rs;int i,k=1;system("CLS");printf("请输入需要输入几个学生信息:"); scanf("%d",&rs);for(i=shuliang;i<shuliang+rs;i++,k++){printf("请输入第%d个学生的学号:",k); scanf("%d",&student[i].number); printf("请输入学生的姓名:");scanf("%s",student[i].name);printf("请输入学生3门课的成绩:"); printf("请输入第1门课的成绩:"); scanf("%d",&student[i].gaoshu); printf("请输入第2门课的成绩:"); scanf("%d",&student[i].yingyu); printf("请输入第3门课的成绩:");scanf("%d",&student[i].jisuanji);}shuliang=shuliang+rs;fhzjm();}void ShanChu(){char shanchuinfo[10];system("CLS");printf("删除全部学生信息请输入\"all\",删除指定学号的学生信息请输入\"one\"\n");scanf("%s",shanchuinfo);if(strcmp(shanchuinfo,"all")==0){int j;printf("你删除的学生信息如下:\n");printf("-----------学号-------------姓名-------------高数--------------英语--------------计算机\t\n");for(j=0;j<shuliang;j++)printf("----%d-------%s-------%d-------%d-------%d\t\n",student[j].number,student[j].name,student[j].gaos hu,student[j].jisuanji);shuliang=0;printf("删除成功\n\n");}else if(strcmp(shanchuinfo,"one")==0) {struct student *p=NULL;int choice;int i,j,k=0;printf("请输入你要删除的人的学号:"); scanf("%d",&choice);for(i=0;i<shuliang;i++){if(choice==student[i].number){k=1;j=i;break; }}if(k){if(shuliang==1) {p=&student[0]; free(p); shuliang=0;}else{for(i=j;i<shuliang;i++) {student[i]=student[i+1]; }shuliang=shuliang-1; }printf("删除成功\n\n"); }else{printf("输入数据错误!\n"); }}fhzjm();}void LiuLan(){int i;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息!\n");}else{for(i=0;i<shuliang;i++){printf("第%d个学生的学号为:%d\n",i+1,student[i].number); printf("第%d个学生的姓名为:%s\n",i+1,student[i].name); printf("第%d个学生的第一门课的成绩为:%d\n",i+1,student[i].gaoshu);printf("第%d个学生的第二门课的成绩为:%d\n",i+1,student[i].yingyu);printf("第%d个学生的第三门课的成绩为:%d\n",i+1,student[i].jisuanji);student[i].sum=student[i].gaoshu+student[i].yingyu+stude nt[i].jisuanji;printf("第%d个学生的总成绩为:%d\n",i+1,student[i].sum);}}fhzjm();}void ChaZhao(){int xx;char choice,yy[20];int i,j,k=0;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息!\n"); fhzjm();}printf("三种查找方式:学号,姓名,成绩\n");printf("如果按学号查找请输1,如果按姓名查找请输2,如果按成绩查找请输3\n");printf("请输入您查找的方式:");scanf("%s",&choice);if(choice=='1'){printf("请输入需要查找学生的学号:");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].number){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,st udent[j].yingyu,student[i].jisuanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='2'){printf("请输入需要查找学生的姓名:\n");scanf("%s",yy);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(strcmp(yy,student[i].name)==0){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,st udent[j].yingyu,student[j].jisuanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='3'){printf("请输入需要查找学生的成绩:\n");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数----英语----计算机----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].grade){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,st udent[j].yingyu,student[i].jisuanji);}}if(k==0)printf("输入信息有误:\n");}fhzjm();}void PaiXu(){struct student *p1[N],**p2,*temp; int i,j;system("CLS");p2=p1;for( i=0;i<shuliang;i++){p1[i]=student+i;}for( i=0;i<shuliang;i++){for( j=i+1;j<shuliang;j++){if((*(p2+i))->sum<(*(p2+j))->sum){temp=*(p2+i);*(p2+i)=*(p2+j);*(p2+j)=temp;}}printf("按照总成绩排序之后的信息为:\n");printf("----学号----姓名----总成绩----\t\n");for( i=0;i<shuliang;i++){student[i].sum=student[i].gaoshu+student[i].yingyu+stude nt[i].jisuanji;printf("----%d-----%s----%d-----\n",(*(p2+i))->number,(*(p2+i))->name,(*(p2+i))->sum);}fhzjm();void CunChu(){int i;FILE *rs;if((rs=fopen("student.txt","w"))==NULL) {printf("not open");exit(0);}for(i=0;i<shuliang;i++)fwrite(&student[i], sizeof(student[i]), 1, rs); }if(ferror(rs)){fclose(rs);perror("写文件失败!\n");return;}printf("存储文件成功!\n");fclose(rs);}void DaoChu(){struct student t;int i=0;FILE* fp = fopen("student.txt", "r"); shuliang=0;if(NULL==fp){perror("读取文件打开失败!\n");}memset(student,0x0,sizeof(student)); while(1){fread(&t,sizeof(t),1,fp);if(ferror(fp)){fclose(fp);perror("读文件过程失败!\n"); return;}if(feof(fp)){break;}student[i]=t;i++;}fclose(fp);shuliang=i;printf("导出文件成功!\n");fhzjm();}void menu(){int n=0;system("CLS");printf(" 学生信息管理系统\n");printf(" 作者:陈椿\n");printf("-------------------MENU-----------------\n"); printf(" 1.登记学生信息\n");printf(" 2.删除学生信息\n");printf(" 3.浏览所有已经登记的学生\n"); printf(" 4.查找\n");printf(" 4.1按学号查找\n");printf(" 4.2按姓名查找\n");printf(" 4.3按成绩查找\n");printf(" 5.根据总成绩排序\n");printf(" 6.存储到文件\n");printf(" 7.从文件导出\n");printf(" 8.退出系统\n");a: printf(" 请选择:");scanf("%d",&n);switch (n){case 1:DengJi();break; case 2: ShanChu();break; case 3:LiuLan();break; case 4: ChaZhao();break; case 5:PaiXu();break;case 6:CunChu();break;case 7:DaoChu();break;case 8:exit(0);break;default:{printf("请输入1-8之间的数字,谢谢!\n"); goto a;}}}main() { menu(); }。
学生信息管理系统C语言源代码
#include<stdio.h>#include<malloc.h>#include<string.h>#include<stdlib.h>#define len sizeof(struct student)FILE *fp;struct student{long num;char name[15];int age;char sex[3];char chushen[10];char dizhi[20];char phone[11];char email[20];struct student *next;};void menu(){printf("===========学生信息管理系统==========\n\n");printf(" 1、录入学生信息\n");printf(" 2、浏览学生信息\n");printf(" 3、查询学生信息\n");printf(" 4、删除学生信息\n");printf(" 5、插入学生信息\n");printf(" 6、修改学生信息\n");printf(" 7、排序学生信息\n");printf(" 8、退出管理系统\n");printf("=====================================\n");}struct student *creat() //录入学生信息{int n;struct student *head;struct student *p1,*p2;n=0;p1=p2=(struct student *) malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chushen ,p1->dizhi,p1->phone,p1->email);head=NULL;while(p1->num!=0){n=n+1;if(n==1) head=p1;else p2->next=p1;p2=p1;p1=(struct student *)malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chu shen,p1->dizhi,p1->phone,p1->email);}p2->next=NULL;return(head);}void insert(struct student *head) //插入学生信息{int search_num;struct student *p,*q,*s;p=head;printf("在哪个学生前插入请输入学号:\n");scanf("%d",&search_num);while((p!=NULL)&&(p->num!=search_num)){q=p;p=p->next;}s=(struct student *)malloc(len);q->next=s;system("cls");printf("请输入学生信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&s->num,&s->age,s->name,s->sex,s->chushen,s->diz hi,s->phone,s->email);s->next=p;}void printList(struct student *head) //浏览全部学生信息{struct student *p;p=head;if(head==NULL)printf("没有学生信息!!\n");else{do{fread(p,len,1,fp);printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);p=p->next;}while(p!=NULL);}}void findList_num(struct student *head,long search_num) //按学号查找{struct student *p;p=head;while((p!=NULL)&&(p->num!=search_num))p=p->next;if(p!=NULL)printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);elseprintf("没有该学生信息!!\n");}void findList_name(struct student *head,char *search_name) //按姓名查找{struct student *p;int cmp1=0,cmp=0;p=head;while(p!=NULL)if(strcmp(p->name,search_name)!=0){p=p->next;cmp++;}else{printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->dizhi,p->phone,p->email);p=p->next;cmp1=1;}if(cmp!=0&&cmp1==0)printf("没有该学生信息!!\n");}void xiugai(struct student *p1,long xiu_num) //修改学生信息{struct student *p2;p2=p1;while((p2!=NULL)&&(p2->num!=xiu_num))p2=p2->next;if(p2!=NULL){scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p2->num,&p2->age,p2->name,p2->sex,p2->chu shen,p2->dizhi,p2->phone,p2->email);}elseprintf("没有该学生信息!!\n");}struct student *delList(struct student *head,long del_num) // 删除学生信息{struct student *p,*q;p=head;q=head;while(p &&(p->num != del_num)){q=p;p=p->next;}if(p==NULL)printf("无此学号!\n");else{if(p == head){head = p->next;free(p);}else{q->next = p->next;free(p);}}return head;}void paixu(struct student *head) //按学号排序{struct student *p,*f,*t;char ch[100];int i;t=f=p=head;for(p=head;p->next!=NULL;p=p->next){for(t=head,f=t->next;t->next!=NULL;t=t->next,f=f->next){if(t->num>f->num>0){i=t->num;t->num=f->num;f->num=i;i=t->age;t->age=f->age;f->age=i;strcpy(ch,t->name);strcpy(t->name,f->name);strcpy(f->name,ch);strcpy(ch,t->sex);strcpy(t->sex,f->sex);strcpy(f->sex,ch);strcpy(ch,t->chushen);strcpy(t->chushen,f->chushen);strcpy(f->chushen,ch);strcpy(ch,t->dizhi);strcpy(t->dizhi,f->dizhi);strcpy(f->dizhi,ch);strcpy(ch,t->phone);strcpy(t->phone,f->phone);strcpy(f->phone,ch);strcpy(ch,t->email);strcpy(t->email,f->email);strcpy(f->email,ch);}}}// return head;}void save(struct student *head) //保存为磁盘文件{struct student *p;if((fp=fopen("keshe","w"))==NULL){printf("cannot open this file\n");exit(0);}p=head;while(p!=NULL){fprintf(fp,"%d\n",p->num);fprintf(fp,"%d\n",p->age);fprintf(fp,"%s\n",p->name);fprintf(fp,"%s\n",p->sex);fprintf(fp,"%s\n",p->chushen);fprintf(fp,"%s\n",p->dizhi);fprintf(fp,"%s\n",p->phone);fprintf(fp,"%s\n",p->email);p=p->next;}fclose(fp);}struct student *read() //从磁盘读取文件{struct student *head=NULL;struct student *p=NULL;struct student *t=NULL;int a;// fp=fopen("keshe","r");if((fp=fopen("keshe","r"))==NULL){printf("cannot open this file\n");exit(0);}while(1){t=(struct student *)malloc(len);a=fscanf(fp,"%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&t->num,&t->age,t->name,t->sex,t->chush en,t->dizhi,t->phone,t->email);if(a==0||a==-1)return head;t->next=NULL;if(p==NULL){p=t;head=t;}else{p->next=t;p=p->next;p->next=NULL;}}fclose(fp);}void main(){int code=0;struct student *pt = NULL;while(code!=8){menu();printf("请输入上述序号进行操作:\n");scanf("%d",&code);system("cls");switch(code){case 1:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=creat();save(pt);system("cls");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("************录入学生信息成功***********!!\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 2:{system("cls");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();printList(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 3:{int search=0;system("cls");printf("===========================查询学生信息==============================\n");printf("---------------------------------------------------------------------\n");while(search!=3){printf("1、按学号查询\n2、按姓名查询\n3、退出查询\n");scanf("%d",&search);switch(search){case 1:{long search_num;system("cls");printf("请输入学生学号\n");scanf("%d",&search_num);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 2:{char search_name[15];system("cls");printf("请输入学生姓名\n");scanf("%s",search_name);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_name(read(),search_name);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};}}system("cls");};break;case 4:{long del_num;system("cls");printf("===========================删除学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("请输入要删除学生信息的学号:\n");scanf("%d",&del_num);system("cls");pt=delList(read(),del_num);save(pt);printf("===========================删除结果================================\n");printf("-------------------------------------------------------------------\n");printf("学号为%d的学生信息成功删除\n",del_num);printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 5:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");insert(pt);save(pt);system("cls");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("****插入学生信息成功***!!\n\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");}break;case 6:{long search_num;system("cls");printf("请输入要修改的学生学号:\n");scanf("%d",&search_num);system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================修改学生信息==================================\n");printf("-------------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("\n");printf("请输入修改信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();xiugai(pt,search_num);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("****修改学生信息成功***!!\n\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 7:{system("cls");printf(" 按学号从小到大排序\n\n");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();paixu(pt);printList(pt);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 8:read();break;}}}。
C语言课设学生管理系统源代码
说明:只提供源代码,有些需要自己创建文件请自行建立。
#include<stdio.h> /*I/O函数*/#include <conio.h>#include<stdlib.h> /*其它说明*/#include<string.h> /*字符串函数*/#define LEN 15 /* 学号和姓名最大字符数,实际请更改*/#define N 100 /* 最大学生人数,实际请更改*/struct record /*结构体*/{char code[LEN+1]; /* 学号*/char name[LEN+1]; /* 姓名*/int age; /* 年龄*/char sex[3]; /* 性别*/char time[LEN+1]; /* 出生年月*/char add[30]; /* 家庭地址*/char tel[LEN+1]; /* 电话号码*/char mail[30]; /* 电子邮件地址*/char password[20];/*密码*/char maogao[20];char gaoshu[20];char cyuyan[20];}stu[N];int k=1,n,m; /* 定义全局变量*/void readfile();/* 函数声明*/void seek();void modify();void insert();void del();void display();void save();void menu();void panduan();void mima();void students();void xueshengdenglu();void LogOn();void readfile1();void readfile2();void modify1();void mimacharge();void GetPassword(char *szFinalPass);void teachlogon();void insertchengji();int main(){ system("color 1a");while(k)panduan();system("pause");return 0;}void teachlogon(){}void insertchengji(){int i,k,item,num;k=0;char sex1[3],s1[LEN+1],s2[LEN+1]; /* 以姓名和学号最长长度+1为准*/ printf("请输入要要修改的学生的学号:");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].code,s1)==0) /*比较字符串是否相等*/{ k=1;printf("\n\n") ;printf("::∴★∵**☆.∴★∵**☆. 1.登记毛概分数\n");printf(" █████.☆.∵★∵∴☆. 2.登记高数分数\n");printf(" █田█田█.*☆.∴★∵. 3.登记C语言分数\n"); printf(" █田█田█.★∵∴☆.★∵∴.4.返回上层菜单\n");printf(" █田█田█.★∵∴☆.★..**.\n");printf(" █田█田█.★★∵∴☆.★*☆.\n");printf(" █████.\n");printf("◢██□██◣.~~~~~*^_^* \n ");printf("------------------\n");printf("------------------\n");while(1){printf("\n请选择子菜单编号:");scanf("%d",&item);switch(item){case 1:printf("\n请输入毛概分数:");scanf("%s",s2);strcpy(stu[i].maogao,s2);save();printf("\t\t\tO(∩_∩)O登录成功\n"); break;case 2:printf("\n请输入高数分数:");scanf("%s",stu[i].gaoshu);save();printf("\t\t\tO(∩_∩)O修改成功\n");break;case 3:printf("\n请输入C语言分数:");scanf("%s",sex1);strcpy(stu[i].cyuyan,sex1); save();printf("\t\t\tO(∩_∩)O修改成功\n");break;case 4:panduan();break;default:printf("\n请在-8之间选择\n");}}}if(k==0){printf("\n\t\t*****/(ㄒoㄒ)/~~输入的学号有误*******\n\n");system("pause");system("cls");menu();}}void panduan(){char i,j;printf("\n∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞【学生信息管理系统】∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞\n");printf(" --------------------------------系统菜单显示如下------------------------------");printf("\n");printf("\n\t ①============【学生登录】\n");printf("\n\t ②============【管理员登录】\n");printf("\n\t ③============【退出系统】\n");printf("\n\n");printf("\t\t#〓§〓〓〓〓〓§〓〓〓〓〓〓§〓〓〓〓〓§〓#\n");printf("\t\t↓↓↓↓\n");printf("\t\t☆★☆☆★☆☆★☆☆★☆\n");printf("\t\t☆北☆☆京☆☆化☆☆工☆\n");printf("\t\t☆★☆☆★☆☆★☆☆★☆\n");printf("\t\t↓↓↓↓\n");printf("\t\t※※※※\n");scanf("%s",&i);switch(i){case('1'):system("cls");students();break;case('2'):system("cls");mima();break;case('3'): exit(0);break;case('4'):insertchengji();break;default:printf("请在1-3之间选择\n");}}void mimacharge(){ char username[16],password[20],password1[20],password2[20],q;int i,j,num,item;int k=0;printf("\n\n");printf(" 请输入学号: ");scanf("%s",username);for(i=0;i<=n;i++)if(strcmp(stu[i].code,username)==0){k=1;printf("\n\n");printf(" 请输入密码:");scanf(" %s",password);if(strcmp(stu[i].password,password) ==0){ printf("\n\n");printf(" 请输入新的密码: ");scanf(" %s",password1);printf("\n\n");printf(" 请再次输入新密码: ");scanf("%s",password2);if(strcmp(password1,password2)==0){strcpy(stu[i].password,password1);save();printf("\n\n");printf(" 密码修改完毕\n");printf("\n\n");printf(" 按任意键返回上层菜单");system("pause");students();}else{system("cls");printf("\n\n");printf(" 两次输入的密码不一致,请重新输入\n");mimacharge();}}else{ printf("\n\n");system("cls");printf("\n\n");printf(" 输入密码有误,请重新输入\n");mimacharge();}}if (k==0){system("cls");printf("\n\n");printf(" 输入的学号有误,请重新输入\n");mimacharge();}}void modify1(){char username[20],password[20];char szPassword[128];char sex1[3],s1[LEN+1],s2[LEN+1];int i,j,num,item;int k=0;printf("\n 请输入学号:");scanf("%s",username);for(i=0;i<n;i++)if(strcmp(stu[i].code,username)==0){ int k=1;printf("\n 请输入密码(默认密码为0000):"); //开始以不回显且支持退格方式获取输入密码GetPassword(szPassword);if(strcmp(stu[i].password,szPassword) ==0){ system("cls");printf("\n\t\t\t\t登录成功!\n\n\n");num=i;printf("::∴★∵**☆.∴★∵**☆. 1.修改姓名\n");printf(" █████.☆.∵★∵∴☆. 2.修改年龄\n");printf(" █田█田█.*☆.∴★∵. 3.修改性别\n");printf(" █田█田█.★∵∴☆.★∵∴.4.修改出生年月\n");printf(" █田█田█.★∵∴☆.★..**.5.修改地址\n");printf(" █田█田█.★★∵∴☆.★*☆.6.修改电话号码\n");printf(" █████.7.修改E-mail地址\n"); printf("◢██□██◣.~~~~~*^_^* 8.退出本菜单\n ");printf("------------------\n");printf("------------------\n");while(1){printf("请选择子菜单编号:");scanf("%d",&item);switch(item){case 1:printf("请输入新的姓名:\n");scanf("%s",s2);strcpy(stu[num].name,s2); save();printf("\t\t\tO(∩_∩)O修改成功\n");break; case 2:printf("请输入新的年龄:\n");scanf("%d",&stu[num].age);save();printf("\t\t\tO(∩_∩)O修改成功\n");break; case 3:printf("请输入新的性别:\n");scanf("%s",sex1);strcpy(stu[num].sex,sex1);save();printf("\t\t\tO(∩_∩)O修改成功\n"); break; case 4:printf("请输入新的出生年月:\n");scanf("%s",s2);strcpy(stu[num].time,s2);save(); printf("\t\t\tO(∩_∩)O修改成功\n");break; case 5:printf("请输入新的地址:\n");scanf("%s",s2);strcpy(stu[num].add,s2);save();printf("\t\t\tO(∩_∩)O修改成功\n"); break;printf("请输入新的电话号码:\n");scanf("%s",s2);strcpy(stu[num].tel,s2);save();printf("\t\t\tO(∩_∩)O修改成功\n"); break;case 7:printf("请输入新的E-mail地址:\n");scanf("%s",s2);strcpy(stu[num].mail,s2);save(); printf("\t\t\tO(∩_∩)O修改成功\n");break;case 8:students();break;default:printf("请在0-8之间选择\n");}}}else{ system("cls");printf("\n\t**************~~~~(>_<)~~~~ 输入密码有误**************\n");modify1();}}if(k==0){ system("cls");printf("\n");printf("\n\t*******~~~~(>_<)~~~~ 输入的学号有误,请重新输入**********\n");modify1();}}void lookchengji(){char szFinalPass[30];char szPassword[128];char s1[21],password[20];int i,j;int k=0;printf("\n 请输入学号:");scanf("%s",s1);for(i=0;i<=n;i++)if(strcmp(stu[i].code,s1)==0){k=1;printf("\n 请输入密码(默认密码为0000):"); //开始以不回显且支持退格方式获取输入密码GetPassword(szPassword);if(strcmp(stu[i].password,szPassword) ==0){system("cls");printf("\n\n\n");printf("------------------------你的信息如下----------------------------------\n");printf("\n");printf("毛概成绩高数成绩C语言成绩\n");printf("--------------------------------------------------------------------\n");printf("%7s %6s %6s\n",stu[i].maogao,stu[i].gaoshu,stu[i].cyuyan);printf("--------------------------------------------------------------------\n");printf("\n");printf("\n");printf("\n\n按任意键返回学生菜单");system("pause") ;students();}else{system("cls");printf("\n***************~~~~(>_<)~~~~ 输入密码有误,请重新输入**********************\n");LogOn();}if (k==0){ system("cls");printf("\n");printf("\t\t*********(>_<)****输入的学号有误,请重新输入**********\n");}LogOn();}void LogOn(){char szFinalPass[30];char szPassword[128];char s1[21],password[20];int i,j;int k=0;printf("\n 请输入学号:");scanf("%s",s1);for(i=0;i<=n;i++)if(strcmp(stu[i].code,s1)==0){k=1;printf("\n 请输入密码(默认密码为0000):"); //开始以不回显且支持退格方式获取输入密码GetPassword(szPassword);if(strcmp(stu[i].password,szPassword) ==0){system("cls");printf("\n\n\n");printf("------------------------你的信息如下----------------------------------\n");printf("\n");printf("学生学号学生姓名年龄性别出生年月地址电话printf("--------------------------------------------------------------------\n");printf("%6s %7s %6d %5s %9s %8s %10s %14s\n",stu[i].code,stu[i].name,stu[i].age,stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail);printf("--------------------------------------------------------------------\n");printf("\n");printf("\b");printf("\n\n按任意键返回学生菜单");system("pause") ;students();}else{system("cls");printf("\n***************~~~~(>_<)~~~~ 输入密码有误,请重新输入**********************\n");LogOn();}}if (k==0){ system("cls");printf("\n");printf("\t\t*********(>_<)****输入的学号有误,请重新输入**********\n");}LogOn();}void mima(){char szFinalPass[30];char szPassword[128];int k;char j1[20]="123";printf("\n\n");printf(" 请输入管理员密码:");GetPassword(szPassword);if(strcmp(j1,szPassword)==0){k=1;}else{k=2;}switch(k){case(1):system("cls");menu();break;case(2): printf("\n\n 输入的密码有误,按任意键返回上层菜单!\n");system("pause");system("cls");panduan();break;}}void students(){int i;readfile1();printf("\n\n");printf(" ********O(∩_∩)O欢迎您来到学生信息查询系统**********\n");printf("\n\n");printf(" 您需要以下哪项功能请输入对应数字O(∩_∩)O \n") ;printf("\n\n");printf("\t﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩\n");printf("\t﹩﹩\n");printf("\t﹩欢迎使用﹩\n");printf("\t﹩﹩\n");printf("\t﹩0 .刷新学生信息﹩\n");printf("\t﹩﹩\n");printf("\t﹩ 1.查看学生信息﹩\n");printf("\t﹩﹩\n");printf("\t﹩ 2.修改学生信息﹩\n");printf("\t﹩﹩\n");printf("\t﹩ 3.修改密码﹩\n");printf("\t﹩﹩\n");printf("\t﹩ 4.查看学生成绩﹩\n");printf("\t﹩﹩\n");printf("\t﹩ 5.返回上层菜单﹩\n");printf("\t﹩﹩\n");printf("\t﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩﹩\n");scanf("%d",&i);switch(i){case(0):system("cls");readfile2();break;case(1):system("cls");LogOn();break;case(2):system("cls");modify1();break;case(3):system("cls");mimacharge();break;case(4):system("cls");lookchengji();break;case(5):system("cls");panduan();break;default:system("cls");printf("\n\n 请输入0-5的数字,按任意键返回上一菜单\n");system("pause");students();break;}}void help(){printf("\n0.欢迎使用系统帮助!\n");printf("\n1.本系统由309为您提供;\n");printf("\n2.按照菜单提示键入数字代号;\n");printf("\n3.如有疑问或者遇到bug请联系309小组;\n");printf("\n4.谢谢您的使用!O(∩_∩)O\n\n\n");void readfile1()/* 建立信息*/{char *p="student.txt";FILE *fp;int i=0;if ((fp=fopen("D:\\student.txt","r"))==NULL){printf("Open file %s error! Strike any key to exit!",p);system("pause");exit(0);}while(fscanf(fp,"%s %s%d%s %s %s %s %s %s %s %s %s ",stu[i].code,stu[i].name,&stu[i].age, stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail,stu[i].password,stu[i].maogao,stu[i].gaoshu,stu[ i].cyuyan)==12){i++;i=i;}fclose(fp);n=i;}void readfile2()/* 建立信息*/{char *p="student.txt";FILE *fp;int i=0;if ((fp=fopen("D:\\student.txt","r"))==NULL){printf("Open file %s error! Strike any key to exit!",p);system("pause");exit(0);}while(fscanf(fp,"%s %s %d %s %s %s %s %s %s %s %s %s",stu[i].code,stu[i].name,&stu[i]. age,stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail,stu[i].password,stu[i].maogao,stu[i].gaoshu,stu[i].cyuyan)==12){i++;i=i;}fclose(fp);n=i;students();}void readfile()/* 建立信息*/{char *p="student.txt";FILE *fp;int i=0;if ((fp=fopen("D:\\student.txt","r"))==NULL){printf("Open file %s error! Strike any key to exit!",p);system("pause");exit(0);}while(fscanf(fp,"%s %s%d%s %s %s %s %s %s %s %s %s ",stu[i].code,stu[i].name,&stu[i].age, stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail,stu[i].password,stu[i].maogao,stu[i].gaoshu,stu[i].cyuyan)==12){i++;i=i;}fclose(fp);n=i;}void seek() /*查找*/{int i,item,flag;char s1[21]; /* 以姓名和学号最长长度+1为准*/printf("\n\t\t********O(∩_∩)O欢迎来到查询系统,请按提示操作******\n\n");printf("╭⌒╮¤` \n") ;printf("╭╭⌒╮●╭○╮ 1.按学号查询\n");printf("╰----╯/█∨█\\ 2.按姓名查询\n");printf("~~~~~~~~~~∏~~∏~~~~~~~~~~~ 3.返回上层菜单\n");while(1){printf("\n请选择子菜单编号:");scanf("%d",&item);flag=0;switch(item){case 1:printf("\n请输入要查询的学生的学号:");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].code,s1)==0){flag=1;printf("\n\n\t\t\tO(∩_∩)O~~您要查找的信息如下\n\n");printf("学生学号学生姓名年龄性别出生年月地址电话E-mail\n"); printf("--------------------------------------------------------------------\n");printf("%6s %7s %6d %5s %9s %8s %10s %14s\n",stu[i].code,stu[i].name,stu[i].age, stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail);printf("\n\n");system("pause");system("cls");seek();break;}if(flag==0){system("cls");printf("\n\t\t\t~~o(>_<)o ~~该学号不存在,请重新选择*********\n");seek();break;};break;case 2:printf("\n请输入要查询的学生的姓名:");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].name,s1)==0){flag=1;printf("\n\n\t\t\tO(∩_∩)O~~您要查找的信息如下\n\n");printf("学生学号学生姓名年龄性别出生年月地址电话E-mail\n"); printf("--------------------------------------------------------------------\n");printf("%6s %7s %6d %5s %9s %8s %10s %14s\n",stu[i].code,stu[i].name,stu[i].age, stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail);printf("\n\n");system("pause");system("cls");seek();}if(flag==0){ system("cls");printf("\n\t\t\t~~o(>_<)o ~~该姓名不存在*********\n");seek();}break;case 3:system("cls");menu();break;default:system("cls");printf("\n\t\t\t***~\(≧▽≦)/~请在1-3之间选择********\n");seek();}}}void modify() /*修改信息*/{int i,k,item,num;k=0;char sex1[3],s1[LEN+1],s2[LEN+1]; /* 以姓名和学号最长长度+1为准*/ printf("请输入要要修改的学生的学号:");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].code,s1)==0) /*比较字符串是否相等*/{ k=1;num=i;printf("\n\n") ;printf("::∴★∵**☆.∴★∵**☆. 1.修改姓名\n");printf(" █████.☆.∵★∵∴☆. 2.修改年龄\n");printf(" █田█田█.*☆.∴★∵. 3.修改性别\n");printf(" █田█田█.★∵∴☆.★∵∴.4.修改出生年月\n"); printf(" █田█田█.★∵∴☆.★..**.5.修改地址\n");printf(" █田█田█.★★∵∴☆.★*☆.6.修改电话号码\n"); printf(" █████.7.修改E-mail地址\n"); printf("◢██□██◣.~~~~~*^_^* 8.退出本菜单\n ");printf("------------------\n");printf("------------------\n");while(1){printf("\n请选择子菜单编号:");scanf("%d",&item);switch(item){case 1:printf("\n请输入新的姓名:");scanf("%s",s2);strcpy(stu[num].name,s2);save();printf("\t\t\tO(∩_∩)O修改成功\n"); break; case 2:printf("\n请输入新的年龄:");scanf("%d",&stu[num].age);save();printf("\t\t\tO(∩_∩)O修改成功\n");break; case 3:printf("\n请输入新的性别:");scanf("%s",sex1);strcpy(stu[num].sex,sex1); save();printf("\t\t\tO(∩_∩)O修改成功\n");break; case 4:printf("\n请输入新的出生年月:");scanf("%s",s2);strcpy(stu[num].time,s2); save();printf("\t\t\tO(∩_∩)O修改成功\n");break; case 5:printf("\n请输入新的地址:");scanf("%s",s2);strcpy(stu[num].add,s2);save();printf("\t\t\tO(∩_∩)O修改成功\n"); break; case 6:printf("\n请输入新的电话号码:");scanf("%s",s2);strcpy(stu[num].tel,s2);save();printf("\t\t\tO(∩_∩)O修改成功\n"); break; case 7:printf("\n请输入新的E-mail地址:");scanf("%s",s2);strcpy(stu[num].mail,s2);save();printf("\t\t\tO(∩_∩)O修改成功\n"); break; case 8:system("cls");menu();break;default:printf("\n请在-8之间选择\n");}}}if(k==0){printf("\n\t\t*****/(ㄒoㄒ)/~~输入的学号有误*******\n\n");system("pause");system("cls");menu();}}void sort()/*按学号排序*/{int i,j,*p,*q,s;char temp[10];for(i=0;i<n-1;i++){for(j=n-1;j>i;j--)if(strcmp(stu[j-1].code,stu[j].code)>0) {strcpy(temp,stu[j-1].code);strcpy(stu[j-1].code,stu[j].code); strcpy(stu[j].code,temp);strcpy(temp,stu[j-1].name);strcpy(stu[j-1].name,stu[j].name); strcpy(stu[j].name,temp);strcpy(temp,stu[j-1].sex);strcpy(stu[j-1].sex,stu[j].sex);strcpy(stu[j].sex,temp);strcpy(temp,stu[j-1].time);strcpy(stu[j-1].time,stu[j].time); strcpy(stu[j].time,temp);strcpy(temp,stu[j-1].add);strcpy(stu[j-1].add,stu[j].add); strcpy(stu[j].add,temp);strcpy(temp,stu[j-1].tel);strcpy(stu[j-1].tel,stu[j].tel);strcpy(stu[j].tel,temp);strcpy(temp,stu[j-1].mail);strcpy(stu[j-1].mail,stu[j].mail); strcpy(stu[j].mail,temp);p=&stu[j-1].age;q=&stu[j].age;s=*q;*q=*p;*p=s;}}}void insert() /*插入函数*/{ char s1[20]="0000";int i=n,j,flag;printf("请输入待增加的学生数:\n"); scanf("%d",&m);do{flag=1;while(flag){flag=0;printf("请输入第%d 个学生的学号:\n",i+1);scanf("%s",stu[i].code);for(j=0;j<i;j++)if(strcmp(stu[i].code,stu[j].code)==0){printf("已有该学号,请检查后重新录入!\n");flag=1;break; /*如有重复立即退出该层循环,提高判断速度*/}}printf("请输入第%d 个学生的姓名:\n",i+1);scanf("%s",stu[i].name);printf("请输入第%d 个学生的年龄:\n",i+1);scanf("%d",&stu[i].age);printf("请输入第%d 个学生的性别:\n",i+1);scanf("%s",stu[i].sex);printf("请输入第%d 个学生的出生年月:(格式:年.月)\n",i+1); scanf("%s",stu[i].time);printf("请输入第%d 个学生的地址:\n",i+1);scanf("%s",stu[i].add);printf("请输入第%d 个学生的电话:\n",i+1);scanf("%s",stu[i].tel);printf("请输入第%d 个学生的E-mail:\n",i+1);scanf("%s",stu[i].mail);strcpy(stu[i].password,s1);if(flag==0){i=i;i++;}}while(i<n+m);n+=m;printf("录入完毕!\n\n");save();system("pause");system("cls");menu();}void del(){int i,j,flag=0;char s1[LEN+1];printf("请输入要删除学生的学号:\n");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].code,s1)==0){flag=1;for(j=i;j<n-1;j++)stu[j]=stu[j+1];}if(flag==0){printf("\n\t\t****(⊙o⊙)…该学号不存在&&******\n");printf("\n");system("pause");system("cls");menu();}if(flag==1){printf("删除成功,显示结果请选择菜单\n");n--;save();printf("\n");system("pause");system("cls");menu();}}void display(){int i;printf("所有学生的信息为:\n");printf("学生学号学生姓名年龄性别出生年月地址电话E-mail\n"); printf("--------------------------------------------------------------------\n");for(i=0;i<n;i++){printf("%6s %7s %5d %5s %9s %8s %10s %14s\n",stu[i].code,stu[i].name,stu[i].age, stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail);}printf("\n\n");system("pause");system("cls");menu();}void save(){sort();int i;FILE *fp;fp=fopen("D:\\student.txt","w"); /*写入*/for(i=0;i<n;i++){fprintf(fp,"%s %s %d %s %s %s %s %s %s %s %s %s\n",stu[i].code,stu[i].name,stu[i].age,stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail,stu[i].password,stu[i].maogao,stu[i].gaoshu,stu[ i].cyuyan);}fclose(fp);}void menu()/* 界面*/{readfile();char num;printf("\n∞∞∞∞∞∞∞∞∞∞【学生信息管理系统(管理员界面)】∞∞∞∞∞∞∞∞∞∞∞∞∞\n");printf(" --------------------------------系统菜单显示如下------------------------------");printf("\n\t①===============【帮助信息】\n");printf("\n\t②===============【刷新数据】\n");printf("\n\t③===============【查询学生信息】\n");printf("\n\t④===============【修改学生信息】\n");printf("\n\t⑤===============【添加学生信息】\n");printf("\n\t⑥===============【删除学生信息】\n");printf("\n\t⑦===============【显示学生信息】\n");printf("\n\t⑧===============【保存学生信息】\n");printf("\n\t⑨===============【返回上层菜单】\n"); printf("请选择菜单编号:");scanf("%s",&num);switch(num){case '1':system("cls");help();system("pause");system("cls");menu();break;case '2':readfile();system("cls");menu();break;case '3':system("cls");seek();break;case '4':system("cls");modify();break;case '5':system("cls");insert();break;case '6':system("cls");del();break;case '7':system("cls");display();break;case '8':system("cls");save();system("cls");printf("\n\t\t\t$$$$O(∩_∩)O~~已保存信息&&&&&&\n\n");system("pause");system("cls");menu();break;case '9':system("cls");panduan();break;default:system("cls");printf("请在1-9之间选择\n");system("pause");system("cls");menu();}}void GetPassword(char *szFinalPass){char chValue,szPassword[20];int iCounter = 0; //定义计数器while ( 1 ){if( ( chValue = getch() ) != '\r' ) //如果输入的不是回车{if( chValue != '\b' ) //如果输入的不是退格{if ( iCounter <20) //如果长度并未超过密码的最大长度{szPassword[iCounter] = chValue;putchar( '*' ); //在屏幕上显示星号iCounter ++;}else{putchar( '\7' ); //如果密码已经超过最大长度,则响铃报警}}else{if( iCounter != 0 ) //如果按了退格,并且当前不是第一个字符{iCounter --;printf( "\b \b" ); //注意两个\b之间是有个空格的,含义是先退格,//然后打印空白字符将之前的字符覆盖掉,然后再退格使光标退回}}}else{szPassword[iCounter] = 0; //密码输入结束时将末尾以\0结尾!break;}}strcpy( szFinalPass ,szPassword ); //最终将密码复制出来}。
C语言学生信息管理系统(源代码)
#include <stdio.h>#include <string.h>/* 谭法建立单链表和输出单链表*/#include <malloc.h>#include <stdlib.h>typedef struct node{ int num;char name[20];struct node *next;}STD;#define LEN sizeof(STD)int menu_select();void handle_menu1();void game4();void game2();STD *insert(STD *head,STD *stud);STD *insert2(STD *head,STD *stud); void game3();void game5();STD *delete(STD*head,long num);void game1();void game6();STD *search(STD*head,long num);STD *head1,*head2;int n=0;/*追加法建表*/void creat1(void){ STD *p1,*p2;system("CLS");head1=NULL;p1=(STD *)malloc(LEN);p2=p1;printf("建表方法1追加法建表!\n");printf("输入学号姓名,若输入学号为0则退出建表!\n");scanf("%d%s",&p1->num,p1->name);while(p1->num!=0){ n++;if(n==1)head1=p1;elsep2->next=p1;p2=p1;p1=(STD *)malloc(LEN);scanf("%d%s",&p1->num,p1->name);}free(p1); p2->next=NULL;scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");return ;}/* 插入法建表*/void creat2(void){ STD *p1;head2=NULL;system("CLS");p1=(STD *)malloc(LEN);printf("建表方法2插入法建表!\n");printf("输入学号姓名(输入学号以0结束)!\n");scanf("%d%s",&p1->num,p1->name);while(p1->num!=0){ p1->next=head2;head2=p1;p1=(STD *)malloc(LEN);scanf("%d%s",&p1->num,p1->name);}scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");free(p1);return ;}/* 链表输出*/void print(STD *head){ STD *p;p=head;while (p!=NULL){ printf("学号%3d 姓名%s\n",p->num,p->name); p=p->next;} printf("链表为空!\n");scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");}/*-------------------------------------------------*//*--------------表1插入结点函数-------*//*-------------------------------------------------*/void game4(){char ch;STD *stud,*head=head1;system("CLS");printf("\t仅限在表1中插入!\n");printf("\t输入要插入结点的学号和姓名(以空格隔开):");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);if(stud->num<0){ printf("\t输入的学号不能为负数,请重新选择插入!\n");return;}while(stud->num>=0){head1=insert(head,stud);printf("\t继续插入新结点吗?(y/n):");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入新结点学号姓名:(输入n结束插入)");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2插入结点函数-------*//*-------------------------------------------------*/void game2(){char ch;STD *stud,*head=head2;system("CLS");printf("\t仅限在表2中插入!\n");printf("\t输入要插入结点的学号和姓名(以空格隔开):");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);if(stud->num<0){ printf("\t输入的学号不能为负数,请重新选择插入!\n");return;}while(stud->num>=0){head2=insert2(head,stud);printf("\t继续插入新结点吗?(y/n):");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入新结点学号姓名:(输入n结束插入)");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 插入模块*//**************************************/STD *insert(STD *head,STD *stud){STD *p0,*p1,*p2;p1=head;p0=stud;if(head==NULL){head=p0;p0->next=NULL;}else{while((p0->num>p1->num)&&(p1->next!=NULL)){p2=p1; p1=p1->next;}if(p0->num<=p1->num){if(head==p1)head=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}n=n+1;printf("按回车键继续!\n");getchar();system("CLS");return (head);}/**************************************//* 插入模块2 *//**************************************/STD *insert2(STD *head,STD *stud){STD *p0,*p1,*p2;p1=head;p0=stud;if(head==NULL){head=p0;p0->next=NULL;}else{while((p0->num<p1->num)&&(p1->next!=NULL)){p2=p1; p1=p1->next;}if(p0->num>=p1->num){if(head==p1)head=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}n=n+1;printf("按回车键继续!\n");getchar();system("CLS");return (head);}/*-------------------------------------------------*//*--------------表1删除学生信息-------*//*-------------------------------------------------*/void game3(){ int num;char ch;STD *head=head1;printf("\t仅限在表1中删除!\n");printf("\t输入要删除的学号:");scanf("%*c");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新选择删除!\n");return;}while(num>=0){head=head1;head1=delete(head,num);printf("\t继续删除吗?(y/n):");scanf("%*c");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要删除的学号:(输入n结束删除!)");scanf("%*c");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2删除学生信息-------*//*-------------------------------------------------*/void game5(){ int num;char ch;STD *head=head2;printf("\t仅限在表2中删除!\n");printf("\t输入要删除的学号:");scanf("%*c");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新选择删除!\n");return;}while(num>=0){head=head2;head2=delete(head,num);printf("\t继续删除吗?(y/n):");scanf("%*c");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要删除的学号:(输入n结束删除!)");scanf("%*c");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 删除模块*//**************************************/STD *delete(STD*head,long num){STD *p1,*p2;if (head==NULL) {printf("\n没有找到该学号!\n");return head;} p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num){if(p1==head)head=p1->next;else p2->next=p1->next;printf("\n删除:%ld\n",num);n=n-1;}elseprintf("\n 没有发现此项! \n",num);system("CLS");return(head);}/*-------------------------------------------------*//*--------------表1查找学生信息-------*//*-------------------------------------------------*/void game1(){ int num;char ch;STD *head=head1;printf("\t仅限在表1中查找!\n");printf("\t输入要查找的学号:");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新查找!\n");return;}while(num>=0){head=head1;head1=search(head,num);printf("\t继续查找吗?(y/n):");scanf("%d",&num);ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要查找的学号:(输入n结束查找)");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2查找学生信息-------*//*-------------------------------------------------*/void game6(){ int num;char ch;STD *head=head2;printf("\t仅限在表2中查找!\n");printf("\t输入要查找的学号:");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新查找!\n");return;}while(num>=0){head=head2;head2=search(head,num);printf("\t继续查找吗?(y/n):");scanf("%d",&num);ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要查找的学号:(输入n结束查找)");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 查找模块*//**************************************/STD *search(STD*head,long num){STD *p1,*p2;if (head==NULL) {printf("\n没有找到该学号!\n");return head;} p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num)printf("\n%d %s\n",p1->num,p1->name);elseprintf("\n 没有发现此项! \n",num);return(head);}/* void main(){printf(" *** 运行结果***\n");printf("输入学号姓名(输入学号以0结束)!\n");creat1();print(head1);creat2();print(head2);} *///******************************//* select.cpp:主程序文件*//******************************void main(){handle_menu1();}//*****************************//* 菜单处理函数*//*****************************void handle_menu1(){int h;for(;;){h=menu_select();switch(h){ case 1:/* printf("\t进入追加法建表\n"); */creat1();break; /* 调用功能模块*/case 2:/* printf("\t进入插入法建表\n"); */creat2();break;case 3:/* printf("\t输出追加法链表的结果\n"); */print(head1);break;case 4:/* printf("\t输出插入法链表的结果\n"); */print(head2);break;case 5:/* printf("\t链表1插入\n"); */game4();break;case 6:/* printf("\t链表2插入\n"); */game2();break;case 7:/* printf("\t链表1删除\n"); */game3();break;case 8:/* printf("\t链表2删除\n"); */game5();break;case 9:/* printf("\t链表1查找\n"); */game1();break;case 10:/* printf("\t链表2查找\n"); */game6();break;case 11:printf("\t再见,欢迎再次使用本系统!谢谢!\n");return;}}}//**********************************//* 菜单选择函数: int menu_select()*//**********************************int menu_select(){int cn;for(;;){printf("\ \n");printf("\t1.追加法建表\n");printf("\ \n");printf("\t2.插入法建表\n");printf("\ \n");printf("\t3.输出链表1\n");printf("\ \n");printf("\t4.输出链表2\n");printf("\ \n");printf("\t5.插入链表1 \n");printf("\ \n");printf("\t6.插入链表2 \n");printf("\ \n");printf("\t7.删除链表1 \n");printf("\ \n");printf("\t8.删除链表2 \n");printf("\ \n");printf("\t9.查找链表1 \n");printf("\ \n");printf("\t10.查找链表2 \n");printf("\ \n");printf("\t11.退出系统\n");printf("\ \n");printf("\t请您选择1-11:");scanf("%d",&cn);//gets(s);//cn=atoi(s);if(cn<1||cn>11)printf("\n\t输入错误,重选1-11:");elsebreak;}return cn;}。
学生信息管理系统C语言程序代码
#include <iostream.h> #include <iomanip.h>#include <fstream>#include <vector>#include <malloc.h>#include <stdlib.h>#include <string>#include <process.h>#include <stdio.h>#define LEN sizeof(struct student)using namespace std;int n=0; //定义一个全局变量统计学生人数struct student//定义一个学生信息的构造体char name[20]; //用来存放姓名的char sex[20]; //用来存放性别的char yuanxi[20];//用来存放院系的long int id; //用来存放学号的int score[4]; //用来存放分数的int total; //用来存放总分数的struct student *next;vector <student> stu;class Informationpublic:Information() ; //构造函数.~Information() ; //析构函数.student *creat();//建立链表函数。
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[20];n=0; //用来存放姓名的p1=p2=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元cout<<" -------------<<请建立学生考试信息表,在姓名处输入! 完毕输入。
学生信息管理系统(C语言版)源代码
#include "stdio.h"#include "stdlib.h"#include "string.h"int shoudsave=0; /* */ struct student{char num[10];/* 学号*/ char name[20];char sex[4];int age;int cgrade;int mgrade;int egrade;int totle;int ave;char xueyuan[30];char banji[20];char ID[30];char phone[20];char address[50];char neartime[10];/* 最近更新时间*/};typedef struct node{struct student data;struct node *next;}Node,*Link;void login()/*登录函数*/{char logname[30];printf("请输入用户名和密码:\n用户名:");scanf("%c",logname);}void menu(){printf("***********************请按照提示操作,否则可能出现错误*************************"); printf("********************************************************************************");printf("\t1登记学生资料\t\t2删除学生资料\t\t7统计学生资料\n");printf("\t3查询学生资料\t\t4修改学生资料\t\t8排序\n");printf("\t5保存学生资料\t\t6输出学生资料\t\t0结束\n");printf("********************************************************************************\n");}void printstart(){printf("-----------------------------------------------------------------------\n");}void Wrong(){printf("\n=====>提示:输入错误!\n");}void Nofind(){printf("\n=====>提示:没有找到该学生!\n");}void printc() /* 本函数用于输出中文*/{printf(" 学号\t 姓名性别年龄英语成绩数学成绩C语言成绩总分平均分学院班级身份证电话住址\n");}void printe(Node *p)/* 本函数用于输出英文*/{printf("%-12s%-8s%-6s%-6d%-6d%-6d%-6d%-6d%-8d%-20s%-15s%-20 s%-15s%-20s\n",p->data.num,p->,p->data.sex,p->data.age,p->data.egrade,p->data.mgrade,p->data.cgrade,p->data.totle,p->data.ave,p ->data.xueyuan,p->data.banji,p->data.ID,p->data.phone,p->data.address);}Node* Locate(Link l,char findmess[],char nameornum[]) /* 该函数用于定位链表中符合要求的接点,幵返回该指针*/{Node *r;if(strcmp(nameornum,"num")==0) /* 按学号查询*/{r=l->next;while(r!=NULL){if(strcmp(r->data.num,findmess)==0)return r;r=r->next;}}else if(strcmp(nameornum,"name")==0) /* 按姓名查询*/ {r=l->next;while(r!=NULL){if(strcmp(r->,findmess)==0)return r;r=r->next;}}return 0;}void Add(Link l) /* 增加学生*/{Node *p,*r,*s;char num[10];r=l;s=l->next;while(r->next!=NULL)r=r->next; /* 将指针置于最末尾*/while(1){printf("请你输入学号(以'0'返回上一级菜单:)");scanf("%s",num);if(strcmp(num,"0")==0)break;while(s){if(strcmp(s->data.num,num)==0){printf("=====>提示:学号为'%s'的学生已经存在,若要修改请你选择'4 修改'!\n",num);printstart();printc();printe(s);printstart();printf("\n");return;}s=s->next;}p=(Node *)malloc(sizeof(Node)); strcpy(p->data.num,num); printf("请你输入姓名:");scanf("%s",p->); getchar();printf("请你输入性别:");scanf("%s",p->data.sex); getchar();printf("请你输入年龄:");scanf("%d",&p->data.age); getchar();printf("请你输入c语言成绩:");scanf("%d",&p->data.cgrade); getchar();printf("请你输入数学成绩:"); scanf("%d",&p->data.mgrade); getchar();printf("请你输入英语成绩:"); scanf("%d",&p->data.egrade); getchar();printf("请你输入学院名:");scanf("%s",&p->data.xueyuan); getchar();printf("请你输入班级:");scanf("%s",&p->data.banji); getchar();printf("请你输入身份证:");scanf("%s",&p->data.ID); getchar();printf("请你输入电话:");scanf("%s",&p->data.phone); getchar();printf("请你输入家庭住址:");scanf("%s",&p->data.address);getchar();p->data.totle=p->data.egrade+p->data.cgrade+p->data.mgrade; p->data.ave=p->data.totle / 3;/* 信息输入已经完成*/p->next=NULL;r->next=p;r=p;shoudsave=1;}}void Qur(Link l) /* 查询学生*/{int sel;char findmess[20];Node *p;if(!l->next)printf("\n=====>提示:没有资料可以查询!\n");return;}printf("\n=====>1按学号查找\n=====>2按姓名查找\n"); scanf("%d",&sel);if(sel==1)/* 学号*/{printf("请你输入要查找的学号:");scanf("%s",findmess);p=Locate(l,findmess,"num");if(p){printf("\t\t\t\t查找结果\n");printstart();printc();printe(p);printstart();}elseNofind();}else if(sel==2) /* 姓名*/{printf("请你输入要查找的姓名:"); scanf("%s",findmess);p=Locate(l,findmess,"name");if(p){printf("\t\t\t\t查找结果\n"); printstart();printc();printe(p);printstart();}elseNofind();}elseWrong();}void Del(Link l) /* 删除*/{int sel;Node *p,*r;char findmess[20];if(!l->next){printf("\n=====>提示:没有资料可以删除!\n");return;}printf("\n=====>1按学号删除\n=====>2按姓名删除\n"); scanf("%d",&sel);if(sel==1){printf("请你输入要删除的学号:");scanf("%s",findmess);p=Locate(l,findmess,"num");if(p){r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);printf("\n=====>提示:该学生已经成功删除!\n"); shoudsave=1;}elseNofind();}else if(sel==2){printf("请你输入要删除的姓名:");scanf("%s",findmess);p=Locate(l,findmess,"name");if(p)r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);printf("\n=====>提示:该学生已经成功删除!\n"); shoudsave=1;}elseNofind();}elseWrong();}void Modify(Link l){Node *p;char findmess[20];if(!l->next){printf("\n=====>提示:没有资料可以修改!\n"); return;}printf("请你输入要修改的学生学号:");scanf("%s",findmess);p=Locate(l,findmess,"num");if(p){printf("请你输入新学号(原来是%s):",p->data.num); scanf("%s",p->data.num);getchar();printf("请你输入新姓名(原来是%s):",p->); scanf("%s",p->);getchar();printf("请你输入新性别(原来是%s):",p->data.sex); scanf("%s",p->data.sex);printf("请你输入新年龄(原来是%d):",p->data.age);scanf("%d",&p->data.age);getchar();printf("请你输入新的c语言成绩(原来是%d分):",p->data.cgrade); scanf("%d",&p->data.cgrade);getchar();printf("请你输入新的数学成绩(原来是%d分):",p->data.mgrade); scanf("%d",&p->data.mgrade);getchar();printf("请你输入新的英语成绩(原来是%d分):",p->data.egrade); scanf("%d",&p->data.egrade);getchar();printf("请你输入新学院名(原来是%s):",p->data.xueyuan);scanf("%s",p->data.xueyuan);getchar();printf("请你输入新班级(原来是%s):",p->data.banji);scanf("%s",p->data.banji);getchar();printf("请你输入新身份证(原来是%s):",p->data.ID);scanf("%s",p->data.ID);getchar();printf("请你输入新电话(原来是%s):",p->data.phone);scanf("%s",p->data.phone);getchar();printf("请你输入新家庭住址(原来是%s):",p->data.address);scanf("%s",p->data.address);getchar();p->data.totle=p->data.egrade+p->data.cgrade+p->data.mgrade; p->data.ave=p->data.totle/3;printf("\n=====>提示:资料修改成功,注意保存!\n");shoudsave=1;}elseNofind();}void Disp(Link l){int count=0;Node *p;p=l->next;if(!p){printf("\n=====>提示:没有资料可以显示!\n"); return;}printf("\t\t\t\t显示结果\n");printstart();printc();printf("\n");while(p){printe(p);p=p->next;}printstart();printf("\n");}void Tongji(Link l){Node *pm,*pe,*pc,*pt,*pa; /* 用于指向分数最高的接点*/ Node *r=l->next;if(!r){printf("\n=====>提示:没有资料可以统计!\n");return ;}pm=pe=pc=pt=pa=r;while(r!=NULL){if(r->data.cgrade>=pc->data.cgrade)pc=r;if(r->data.mgrade>=pm->data.mgrade)pm=r;if(r->data.egrade>=pe->data.egrade)pe=r;if(r->data.totle>=pt->data.totle)pt=r;if(r->data.ave>=pa->data.ave)pa=r;r=r->next;}printf("------------------------------统计结果--------------------------------\n");printf("总分最高者:\t%s %d分\n",pt->,pt->data.totle);printf("平均分最高者:\t%s %d分\n",pa->,pa->data.ave);printf("英语最高者:\t%s %d分\n",pe->,pe->data.egrade);printf("数学最高者:\t%s %d分\n",pm->,pm->data.mgrade);printf("c语言最高者:\t%s %d分\n",pc->,pc->data.cgrade); printstart();}void Sort(Link l){Link ll;Node *p,*rr,*s;int sortoption;ll=(Link)malloc(sizeof(Node)); /* 用于做新的连表*/ll->next=NULL;if(l->next==NULL){printf("\n=====>提示:没有资料可以排序!\n");return ;}p=l->next;printstart();printf ("\t0按学号排序\t\t1按成绩排序");printstart();scanf("%d",&sortoption);if(sortoption==1)while(p){ s=(Node*)malloc(sizeof(Node)); /* 新建接点用于保存信息*/ s->data=p->data;s->next=NULL;rr=ll;while(rr->next!=NULL && rr->next->data.totle>=p->data.totle)rr=rr->next;if(rr->next==NULL)rr->next=s;else{s->next=rr->next;rr->next=s;}p=p->next;}else while(p){ s=(Node*)malloc(sizeof(Node)); /* 新建接点用于保存信息*/s->data=p->data;s->next=NULL;rr=ll;while(rr->next!=NULL && (strcmp(rr->next->data.num,p->data.num))<=0) rr=rr->next;if(rr->next==NULL)rr->next=s;else{s->next=rr->next;rr->next=s;}p=p->next;}free(l);l->next=ll->next;printf("\n=====>提示:排序已经完成!\n"); }void Save(Link l){FILE* fp;Node *p;int flag=1,count=0;fp=fopen("e:\\student","wb");if(fp==NULL){printf("\n=====>提示:重新打开文件时发生错误!\n"); exit(1);}p=l->next;while(p){if(fwrite(p,sizeof(Node),1,fp)==1){p=p->next;count++;}else{flag=0;break;}}if(flag){printf("\n=====>提示:文件保存成功.(有%d条记录已经保存.)\n",count);shoudsave=0;}fclose(fp);}void main(){Link l;/* 连表*/FILE *fp; /* 文件指针*/int sel;char ch;char jian;int count=0;Node *p,*r;printf("\t\t\t\t学生成绩管理系统\n\t\t\t青岛理工大学计算机工程学院计算091\n\t\t\t 梁德智200907030\n");l=(Node*)malloc(sizeof(Node));l->next=NULL;r=l;fp=fopen("e:\\student","rb");if(fp==NULL){printf("\n=====>提示:文件还不存在,是否创建?(y/n)\n");scanf("%c",&jian);if(jian=='y'||jian=='Y')fp=fopen("e:\\student","wb");elseexit(0);}printf("\n=====>提示:文件已经打开,正在导入记录,关闭后打开可执行文件\n");while(!feof(fp)){p=(Node*)malloc(sizeof(Node));if(fread(p,sizeof(Node),1,fp)) /* 将文件的内容放入接点中*/{p->next=NULL;r->next=p;r=p; /* 将该接点挂入连中*/count++;}}fclose(fp); /* 关闭文件*/printf("\n=====>提示:记录导入完毕,共导入%d条记录.\n",count);while(1){menu();printf("请你选择操作:");scanf("%d",&sel);if(sel==0){if(shoudsave==1){ getchar();printf("\n=====>提示:资料已经改动,是否将改动保存到文件中(y/n)?\n"); scanf("%c",&ch);if(ch=='y'||ch=='Y')Save(l);}printf("\n=====>提示:你已经退出系统,再见!\n"); break;}switch(sel){case 1:Add(l);break; /* 增加学生*/case 2:Del(l);break;/* 删除学生*/case 3:Qur(l);break;/* 查询学生*/case 4:Modify(l);break;/* 修改学生*/case 5:Save(l);break;/* 保存学生*/case 6:Disp(l);break;case 7:Tongji(l);break;case 8:Sort(l);break;default: Wrong();getchar();break;}}}。
C语言编写学生管理系统的代码
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>#include<conio.h>struct student{char number[21];char name[21];int age;char sex[3];char birthday[8];}studentArray[100];typedef struct student student;student studentArray[100];char putout[5][12]={"学号","姓名","年龄","性别","出生年月"}; //为格式化输出做准备int count=0;//函数声明部分void explain();void readfile();void searchStudent();void modifyStudent();void addStudent();void delStudent();void printAllstudent();void save();void quit();void initial();void initial(){FILE *fp;char choice='y';int i=0;fp=fopen("e:\\students.txt","r");if(!fp){printf("创建文件失败,即将返回\n");return ;}for(;fread(&studentArray[i],sizeof(struct student),1,fp)!=0;i++);count=i;}//0、说明模块void explain(){printf("\n 很高兴能为您服务\n");printf("\n1.进入本系统,请先刷新学生信息,再查训\n");printf("\n2.您可以根据自己需要的信息键入菜单上的编号\n");printf("\n3.修改学生信息后记得退出前保存信息,以免信息流失\n");printf("\n4.在各个子菜单里按提示操作\n");printf("\n5.谢谢您的使用及支持\n");}//1、刷新模块void readfile(){char *p="students.txt";FILE *fp;int i=0;if((fp=fopen("students.txt","r"))==NULL){printf("打开文件%s出错!请按按任意键返回",p);system("pause");{i++;i=i;}fclose(fp);printf("刷新完毕。
C语言项目实训之学员信息管理系统完整源代码
#define N 200#include<string.h>#include<stdio.h>#include"stdlib.h"/*其他说明*/#include"string.h"/*字符串函数*/#include"conio.h"/*屏幕操作函数*/#include"mem.h"/*内存操作函数*/#include"ctype.h"/*字符操作函数*/#include"alloc.h"/*动态底子分配函数*//*****************************控制学生记录的容量*****************************/ struct student{char num[4];char name[20];int score[6];int sum;float ave;}stu[N];/********************************主函数*********************************/ main(){welcome();}/**********************************欢迎消息****************************/ welcome(){clrscr();/*清屏*/printf("\n\n\n\n\n");printf("\t\t**********************************************\n");/*版本信息*/ printf("\t\t The Student'score management system v1.0\n");printf("\t\t**********************************************\n");printf("\t\t\t BY:Heaven \n");printf("\t\t\t Puyang Vocational College\n");printf("\t\t\t Date:2011.7.29 \n");printf("\t\t**********************************************\n");printf("\t\t Press any key to continue...");/*while(! kbhit());*/getch();/*从键盘读取一个字符,但不显示于屏幕*/system("cls");/*调用DOS的清屏函数,TC中可用clrscr代替*/menu();}/********************************主界面*****************************/menu() /*主界面*/{int n,w1,i;clrscr(); /*清屏幕*/do{puts("\t\t \n\n");puts("\t\t***The Student'score Management System v1.0***\n\n");puts("\t\t\t\tl. Enter new data");puts("\t\t\t\t2. Addition data");puts("\t\t\t\t3. Modify data");puts("\t\t\t\t4. Delete data");puts("\t\t\t\t5. Browse all");puts("\t\t\t\t6. Search by name");puts("\t\t\t\t7. Insert data");puts("\t\t\t\t8. Order by average");puts("\t\t\t\t9. Exit");puts("\n\n\t\t**********************************************\n");printf("\t\tChoice your number(1-9):[]\b\b");scanf("%d",&n);if(n<1||n>9) /*对选择的数字作判断*/ {w1=1;getchar();}else w1=0;}while(w1==1);/*选择功能*/switch(n){case 1:enter();break; /*输入模块*/case 2:add();break; /*追加模块*/case 3:modify();break; /*修改模块*/case 4:del();break; /*删除模块*/case 5:browse();break; /*浏览模块*/case 6:search();break; /*查找模块*/case 7:insert();break; /*插入模块*/case 8:order();break; /*排序模块*/case 9:exit(0);break; /*退出*/}}/***********************************全新保存函数************************/ save(int n) /*保存函数,保存n个记录*/{FILE * fp;int i;if((fp=fopen("score.txt","wb"))==NULL) /*以输出打开方式,在此前的记录被覆盖*/ {printf("\nCannot open file\n");return NULL;}for(i=0;i<n;i++)if (stu[i].ave!=0) /*stu[i].ave=0表示记录已删除*/if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)printf("file write error\n");fclose(fp);}/**********************加载记录或可以计算记录个数的函数***********************/ load() /*加载记录或可以计算记录个数的函数*/{FILE * fp;int i;if((fp=fopen("score.txt","rb"))==NULL) /*以输入找开方式,在此前的记录被覆盖*/ {printf("\nCannot open file\n");return NULL;}for(i=0;! feof(fp);i++)fread(&stu[i],sizeof(struct student),1,fp);fclose(fp);return(i-1); /*返回记录个数*/}/********************一个任务结束时的选择浏览还是返回的函数*******************/ void printf_back() /*一个任务结束时的选择浏览还是返回*/{int k,w;printf("\n\n\tSuccessful.^_^\n\n");printf("What do you want to do?\n\n\t1).Browse all now\t2).Back:[]\b\b");scanf("%d",&w);if(w==1)browse();else menu();}/*******************显示数据结构项目函数*********************/void printf_face() /* 显示数据结构项目*/{printf("\nNO. name score1 score2 score3 score4 score5 score6 sumaverage\n");}sum(int i) /*对第i个记录的分数求总分*/{int j,s;for(s=0,j=0;j<6;j++)s+=stu[i].score[j];stu[i].sum=s;}average(int i) /*对第i个记录的分数求平均值*/{stu[i].ave=stu[i].sum/6.0;}/*************************学号输入函数**************************/no_input(int i,int n) /*i表示第i个的学生信息,n表示比较到第n个学生*/{int j,k,w1;do{w1=0;printf("NO.:");scanf("%s",stu[i].num);for(j=0;stu[i].num[j]!= '\0';j++) /*学号输入函数,作了严格规定*/if(stu[i].num[j]<'0'||stu[i].num[j]>'9') /*判断学号是否为数字*/{puts("Input error! Only be made up of (0-9).Please input again! \n");w1=1;break;}if(w1!=1)for(k=0;k<n;k++) /*比较到第n个学生*//*排除第i个学生记录即你要修改的*/if(k!=i&&strcmp(stu[k].num,stu[i].num)==0) /*判断学号是否有雷同*/{puts("This record is exist.please input again! \n");w1=1;break;}}while(w1==1);}/************************对分数输入*************************/sore_input(int i){int j;for(j=0;j<6;j++){printf("score %d:",j+1);scanf("%d",&stu[i].score[j]);while (stu[i].score[j]>100||stu[i].score[j]<0) /*判断输入的成绩是否是在0到100之间*/ {puts("Input error! Only be made up of (0-100).Please input again! \n");printf("score %d:",j+1);scanf("%d",&stu[i].score[j]);}}}/**********************输入一个记录函数************************/input(int i) /*输入一个记录函数*/{no_input(i,i); /*调用学号输入函数*/printf("name:");scanf("%s",stu[i].name);sum(i); /*调用求总分函数*/average(i); /*调用求平均值函数*/}/*************************显示一个记录的函数***************************/printf_one(int i) /*显示一个记录的函数*/{int j;printf("% -4s % -16s",stu[i].num,stu[i].name);for(j=0;j<6;j++)printf("% -7d",stu[i].score[j]);printf("% -7d",stu[i].sum);printf("% 8.2f\n",stu[i].ave);}void puts_() /*显出--函数*/{puts("\n----------------------------------------------------------------------");}/***********************修改记录函数*************************/modify_data(int i,int n) /*修改数据函数,修改第i个记录*/{int c,w1;clrscr();do /*输入选择作个判断*/{puts("\nmodify by =>\n\n 1).NO. 2).name 3).score1 4).score2\n 5).score3 6).score4 7).score5 8).score6 9).all score 10).all data 11).cancel and back");printf("Which you needed?: []\b\b\b");scanf("%d",&c);if(c>11||c<1){puts("\nChoice error ! Please again !"); /*判断选择是否错误,若是则重新选择性*/getchar(); /*当输入是字符时可以防止死循环*/}}while(c>11||c<1);do{switch(c) /*选择要修改的项目*/{case 1:no_input(i,n);break; /*调用输入函数*/case 2:printf("name:");scanf("%s",stu[i].name);break;case 3:printf("score1:");scanf("%d",&stu[i].score[0]);break;case 4:printf("score2:");scanf("%d",&stu[i].score[1]);break;case 5:printf("score3:");scanf("%d",&stu[i].score[2]);break;case 6:printf("score4:");scanf("%d",&stu[i].score[3]);break;case 7:printf("score5:");scanf("%d",&stu[i].score[4]);break;case 8:printf("score6:");scanf("%d",&stu[i].score[5]);break;case 9:input(i);break; /*调用分数输入函数*/case 10:input(i);break; /*调用输入整条学生记录*/case 11:menu(); /*直接返回主界面*/}if(c>2&&c<10){ sum(i); /*调用求总分函数*/average(i); /*调用求平均值函数*/}puts("\nNow:\n");printf_face(); /*调用显示数据结构项目函数*/printf_one(i); /*修改后的记录让用户确认*/printf("\nAre you sure ?\n\n\t1).Sure 2).No and remodify 3).Cancle []\b\b");/*是否确定*/ scanf("%d",&w1); /*选择2则表示这次修改错误要重新修改*/}while(w1==2);return(w1); /*返回控制值*/}/***********************输入模块**************************/enter() /*输入模块*/{int i,n;printf("How many students(0-%d)?:",N);scanf("%d",&n); /*要输入的记录个数*/printf("\nEnter data now\n\n");for(i=0;i<n;i++){printf("\nInput %dth student record. \n",i+1);input(i); /*调用输入函数*/}if(i!=0)save(n); /*调用输入函数*/printf_back(); /*一个任务结束时让用户选择是浏览还是返回*/}/************************追加模块***************************/add() /*追加模块*/{int i,n,m,k;FILE *fp;n=load();printf("How many students are you want to add(0-%d)?:",N-n);scanf("%d",&m); /*输入要追加的记录个数*/k=m+n;for(i=n;i<k;i++){printf("\nInput %dth student record. \n",i-n+1);input(i); /*调用输入函数*/}if((fp=fopen("score.txt","ab"))==NULL) /*以ab方式打开文件,追加保存*/{printf("cannot open file\n");return;}for(i=n;i<k;i++) /*输入出到文件*/if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)printf("file write error\n");fclose(fp);printf_back(); /*一个任务结束时的选择浏览还是返回*/}/*******************修改模块***********************/modify() /*修改模块*/{struct student s;FILE *fp;int i,n,k,w0=1,w1,w2=0;n=load();do{clrscr();k=-1;/*给用户看全部记录以便确认要修改的记录*/puts_(); /*显示------*/printf_face(); /*调用显示数据结构项目函数*/for(i=0;i<n;i++){if((i!=0)&&(i%10==0)) /*目的是分屏显示*/{printf("\n\nRemember NO. which needed modify. press any key to contiune...");getch();puts("\n\n");}printf_one(i); /*调用显示一个记录的函数*/}puts_();do{printf("\n\nEnter NO. that you want to modify ! NO.:");scanf("%s",s.num); /*输入要修改的数据的学号*/for(i=0;i<n;i++) /*查找要修改的数据*/if(strcmp(s.num,stu[i].num)==0){k=i; /*找到要修改的记录*/s=stu[i]; /*把stu[i](即当次修改的学生记录)备份给s,经便用户反悔时恢复名誉*/}if(k==-1) printf("\n\nNO exist! please again");}while(k==-1); /*当K==-1表示没有找到*/printf_face(); /*调用显示数据结构项目函数*/printf_one(k); /*调用显示一个记录的函数*/w1=modify_data(k,n); /*修改学生记录并且返回保存控制值w1,w1=1则表示用户已确认修改*/if(w1==1) /*w1等于1时则表示用户确定这次修改*/{printf("\nSuccessful^_^.\n\nAre you modify another ?\n\n\t1).Yes 2).Back with save\t[]\b\b");scanf("%d",&w0);save(n); /*每次确定修改后保存*/w2=1; /*来控制保存,使w2=1是标记已有过修改*/}else{w0=0;if(w2==1)stu[k]=s;} /*走到这里是由于用户没有确认这次修改(在调用修改函数w1=modify_data(k,n);时没有确认)。
学生管理系统c语言源代码
学生管理系统c语言源代码学生管理系统c语言源代码#include stdio.h#include dos.h#include string.h#include stdlib.h#include malloc.h#define SIZE 8struct student{char name;char num;int score;float ave;struct student *next;}stu[SIZE],temp,s;void shuru(){int i,j,sum,length,flag=1,a;FILE *fp;while(flag==1){printf(“Define a rangeclass number:");scanf("%d",printf("Input the total number of the class(a):"); scanf("%d",length);if(lengtha)flag=0;}for(i=0;ilength;i++){printf("\n请输入学生的信息:");printf("\n输入姓名:");scanf("%s",stu[i].name);printf("\n输入序号.:");scanf("%s",stu[i].num);printf("\n输入成绩:\n");sum=0;for(j=0;jj++){printf("score %d:",j+1);scanf("%d",stu[i].score[j]);sum+=stu[i].score[j];}stu[i].ave=sum/3.0;}学生管理系统c语言源代码fp=fopen("stu1.txt","w");for(i=0;ilength;i++)if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)printf("File write error\n");fclose(fp);fp=fopen("stu1.txt","r");printf("\name\ NO. score1 score2 score3 sum ave\n");for(i=0;ilength;i++){fread(stu[i],sizeof(struct student),1,fp);printf("%3s%5s%7d%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i ].score,stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score,stu[i].ave);}}void chaxun(){ FILE *fp, *fp1;char n,name;int i,j,k,t,m,flag=1;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");k=i;printf("\nPlease select the menu(1.number ):"); scanf("%d",switch(m){case 1:printf("\nchaxun number:");scanf("%s",n);for(flag=1,i=0;ii++){if(strcmp(n,stu[i].num)==0){j=i;flag=0;break;}}break;case 2:printf("\nchaxun name:");scanf("%s",name);for(flag=1,i=0;ii++){if(strcmp(name,stu[i].name)==0){j=i;flag=0;break;学生管理系统c语言源代码}}}if(!flag){printf("\nYou can find:\n");fp1=fopen("stu2.txt","w");printf(" name NO. score1 score2 score3ave\n");fwrite(stu[j],sizeof(struct student),1,fp1);printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j].score,stu[j].score,stu[j].ave);}else printf("\nNot found!");fclose(fp);fclose(fp1);}xiugai(){ int a;printf("\nplease select the menu(1.CHARU 2.__ ):");scanf("%d",switch(a){case 1:Insert(); break;case 2:Delete(); break;}}Insert(){ FILE *fp;int i,j,t,n;printf("\nNO.:");scanf("%s",s.num);printf("name:");scanf("%s",);printf("score1,score2,score3:");scanf("%d,%d,%d",s.score,s.score,s.score);s.ave=(s.score+s.score+s.score)/3.0;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)学生管理系统c语言源代码printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(t=0;stu[t].aves.avett++);printf("\nnow:\n");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fwrite(s,sizeof(struct student),1,fp);printf("\n%-15s%11s%7d%7d%7d%10.2f",,s.num,s.score,s.score, s.score,s.ave);for(i=t;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);}Delete(){ FILE *fp;int i,j,t,n,flag;char number;if((fp=fopen("stu1.txt","rb"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;学生管理系统c语言源代码printf("\nInput number deleted:");scanf("%s",number);for(flag=1,i=0;flagii++){if(strcmp(number,stu[i].num)==0){for(t=i;tt++){strcpy(stu[t].num,stu[t+1].num);strcpy(stu[t].name,stu[t+1].name);for(j=0;jj++)stu[t].score[j]=stu[t+1].score[j];stu[t].ave=stu[t+1].ave;}n=n-1;elseprintf("\n Not found!");printf("\nNow,the content of file:\n");fp=fopen("stu1.txt","wb");for(i=0;ii++)fwrite(stu[i],sizeof(struct student),1,fp);fclose(fp);fp=fopen("stu1.txt","r");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)printf("%-15s%11s%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i].score, stu[i].score,stu[i].score,stu[i].ave);fclose(fp);}paixu(){FILE *fp;int i,j,n;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(i=0;ii++)for(j=i+1;jj++)学生管理系统c语言源代码if(stu[i].avestu[j].ave){temp=stu[i];stu[i]=stu[j];stu[j]=temp;}printf("\nnow:");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);tongji(){ FILE *fp;int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0; int a10=0; float t;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++){printf("\n%-15s%11s",stu[i].name,stu[i].num); for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);k=i;for(i=0;ii++){labe1=0;if(stu[i].ave60){labe1++;t=labe1/(float)k*100;}}printf("\nbujigelv:");printf("%f%",t);printf("\n");for(j=0;jj++){a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;k=i;printf("kemu is %d:\n",j);for(i=0;ii++)学生管理系统c语言源代码{b=stu[i].score[j]/10;if(b6)a5++;elseif(b=6b7)a6++;elseif(b=7b8)a7++;elseif(b=8b9)a8++;if(b=9b10)a9++;elseif(b==10)a10++;}printf(" 不及格is %d\n",a5);printf(" 60--69 is %d\n",a6);printf(" 70--79 is %d\n",a7);printf(" 80--89 is %d\n",a8);printf(" 90--99 is %d\n",a9);printf(" 100 is %d\n",a10);}}main(){int a;printf(" ____\n"); printf(" 欢迎进入学生成绩管理系统\n");printf(" ____\n"); while(1){printf("\n选择菜单:\n");printf("\n");printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出\n"); scanf("%d",switch(a){case 1: shuru();break;case 2: chaxun(); break;case 3: paixu(); break;case 4: xiugai(); break;学生管理系统c语言源代码case 5: tongji();break; case 6: exit(0); }。
学生管理系统 C语言代码
#include"stdio.h"#include"stdlib.h"#include"string.h"struct stu_info1{char num[13];//学号char name[10];//姓名char sex[5];//性别char cls[20];//班级}stu1[6];struct stu_info2{char counum[6];//课程号char counam[20];//课程名称int credit;//学分}stu2[6];struct stu_info3{char num[13];//学号char counum[6];//课程号float results;//分数}stu3[12];struct stu_info4{char num[13];//学号char counum[6];//课程号float results;//分数}stu4[12];int n=11;void main(){void gengxin();void input1();void input2();void input3();void output();void xianshi();void chaxun();void printf1();void printf2();input1();input2();output();int i;loop: ;printf("*************欢迎使用分数查询系统*************\n");printf("** 请选择**\n");printf("** 1.录入2.删除无用信息(管理员功能) **\n");printf("** 3.显示4.查询(学生功能) **\n");printf("** 5.显示学生信息6.显示课程信息**\n");printf("** 7.退出**\n");printf("**********************************************\n");scanf("%d",&i);switch(i){case 1: input3();break;case 2:gengxin();break;case 3:xianshi();goto loop;case 4: chaxun();goto loop;case 5: printf1();goto loop;case 6: printf2();goto loop;case 7:break;default:printf("error");break;}}void input1()//录入结构体stu1[]{int i;FILE *fp;if((fp=fopen("A.txt","r"))==NULL){printf("can not open file\n");exit(0);}/* printf(" 学号姓名性别班级\n");*/for(i=0;i<=5;i++){fscanf(fp,"%s%s%s%s",&stu1[i].num,&stu1[i].name,&stu1[i].sex,&stu1[i].cls);/*printf("%-13s %-10s %-5s %-20s\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i] .cls);*/}fclose(fp);}void input2()//录入结构体stu2[]{int i;FILE *fp;if((fp=fopen("B.txt","r"))==NULL){printf("can not open file\n");exit(0);}for(i=0;i<=5;i++){fscanf(fp,"%s%s%d",&stu2[i].counum,&stu2[i].counam,&stu2[i].credit);}fclose(fp);}void input3()//录入成绩{FILE *fp;fp=fopen("C.txt","w");int a,i,j,k;float cetss;char number[13],cnum[6],mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){printf("请输入要录入学生成绩的个数\n");scanf("%d",&a);for(i=1;i<=a;i++){printf("请输入要录入的第%d同学的学号:",i);scanf("%s",number);printf("请输入要录入的第%d同学的课程号:",i);scanf("%s",cnum);for(j=0;j<=5;j++)//学号{if((strcmp(number,stu1[j].num)==0))break;}if(j<=5){for(k=0;k<=5;k++)//课程号{if(strcmp(cnum,stu2[k].counum)==0){printf("请输入要录入同学的成绩:");scanf("%f",&cetss);fprintf(fp,"%s %s %f\n",number,cnum,cetss);break;}}}if(j>5||k>5){printf("Error,please input again");i=i-1;}printf("录入成功\n");}}else{printf("密码错误\n");}}void output()// 录入结构体stu3[]{int i;FILE *fp=fopen("C.txt","r");for(i=0;i<n;i++){fscanf(fp,"%s%s%f",&stu3[i].num,&stu3[i].counum,&stu3[i].results);/*printf("%s%s%f\n",stu3[i].num,stu3[i].counum,stu3[i].results);*/ }fclose(fp);}void xianshi()// 显示成绩{int i,j;for(i=0;i<n;i++){for(j=0;j<6;j++){if((strcmp(stu3[i].num,stu1[j].num))==0)printf("%s\t",stu1[j].name);}for(j=0;j<6;j++){if(strcmp(stu3[i].counum,stu2[j].counum)==0)printf("%s\t",stu2[j].counam);}printf("%3.1f\n",stu3[i].results);}}void chaxun()//查询功能{char number[13],c;int i,j,k,a,b,d;while((c=getchar())!='Q'){a=0,b=0;//a记录学分b记录学科printf("请输入要查询同学的学号\n");scanf("%s",number);for(i=0;i<n;i++){if(strcmp(number,stu3[i].num)==0){printf("学号:%s\t",stu3[i].num);for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){printf("姓名:%s\n",stu1[j].name);}}break;}}d=i;for(i=0;i<n;i++)if(strcmp(number,stu3[i].num)==0){b=b+1;for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<6;k++){if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;}break;}}if(stu3[i].results>=60){a=a+stu2[k].credit;printf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,stu2[k].credit);}elseprintf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,0);}if(d<n){printf("共修%d科\t\t实得总学分:%d\n",b,a);}else{printf("学号输入错误\n");}getchar();printf("退出请按Q+回车,继续查询请按回车键");}}void gengxin()//更新信息,删除C.txt中无用信息{FILE *fp;int i,j,k;char mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){fp=fopen("C.txt","w");for(i=0;i<n;i++){for(j=0;j<6;j++)if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<=5;k++)if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;if(k<=5){fprintf(fp,"%s %s %f\n",stu3[i].num,stu3[i].counum,stu3[i].results);}}}printf("更新C.txt成功\n");fclose(fp);}else{printf("密码错误\n");}}void printf1()//显示学生信息{int i;printf(" 学号姓名性别班级\n");for(i=0;i<=5;i++){printf("%-13s%-10s%-5s %-20s\n\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i].cls);}}void printf2()//显示课程信息{int i;printf(" 课程编号课程名称学分\n");for(i=0;i<=5;i++){printf("%-6s%-20s %-4d\n\n",stu2[i].counum,stu2[i].counam,stu2[i].credit);}}。
C语言课程设计——学生管理系统源代码
C语言课程设计——学生管理系统源代码#include〈stdio。
h>#include〈stdlib。
h〉#include<string。
h〉#include〈conio.h>#define MY1 printf(”学号\t姓名\t性别\t年龄\t生日”)#define MY2 printf(”\n%d %6s %4s\t%2d %8d%2d%2d \n",s[i].num,s[i].name,s[i]。
sex,s[i]。
age,s[i]。
a。
year,s[i].a。
month,s[i].a.day)#define MY3 printf(”家庭住址联系方式高数英语大物总成绩")#define MY4 printf(”\n%4s %4s %2d %2d %2d %2d\n”,s[i]。
address,s[i]。
tel,s[i].c。
gao,s[i]。
c.ying,s[i].c.wu,s[i].c.total)#define MAX 30int i;int sum;/*时间结构体类型*/struct date{int year;int month;int day;}a;/*学生成绩结构体类型*/struct score{int gao;int ying;int wu;int total;}c;/*学生信息结构体类型*/struct s_message{int num;char name[20];char sex[5];int age;struct date a;char address[50];char tel [11];struct score c;}s[MAX];/*保存学生信息模块*/int i;FILE*fp;if((fp=fopen(”D:\\s。
txt",”wb”))==NULL){printf(”reading file is wrong!\n”);return;}for (i=0;i<sum;i++){if(fwrite(&s[i],sizeof(struct s_message),1,fp)!=1)printf(”writing file is wrong!\n”);}fclose(fp);}/*读取学生信息模块*/int read_message(){FILE *fp;int i=0;if((fp=fopen("D:\\s。
学生信息管理系统 c源代码
for(i=0;i<sum;i++)
{ if(strcmp(student[i].name,del_name)==0)
{ student[i].num=0;
printf(" %s have deleted!",student[i].name);
break;
}while(i<MAX);
printf("\n press any key to return the main menu!");
getchar();
sum=i;
bioskey(0);
}
output_message()
{ int i=0,j=0,count,page=1;
long num;
char sex;
int age;
char addr[30];
int score;
}student[MAX],b[MAX];
void clrscr()
{ getchar();
system("cls");
}
save_message(int sum)
printf(" Please press any key back!");
bioskey(0);
}
return 0;
}
del_by_name()
{ char del_name[10],i,f=0;
printf("\n\n input name by delete:");
scanf("%ld",&student[i].num);
C语言学生管理系统代码
struct scores *snext;
}stscores;
//宏定义学生个人信息
#define stmes (stmessage *)malloc(sizeof(stmessage)) //为学生个人信息结构体开辟动态内存空间
fflush(stdin);
s--;
}
switch(a)
{
case '1': mainmessage(); continue;//学生基本信息
case '2': mainresult();continue;//学生的成绩信息
case '3': exit(1);//退出系统
void xiugairesult();//修改学生成绩信息
void delatemessag1();//删除学生个人基本信息
void delatemessag2();//删除班级学生基本信息
void delatemessag3();//删除系基本信息
void delatemessag4();//删除全校基本信息
void ziresult4();//学生成绩信息修改菜单
void addmessage();//添加学生基本信息
void judgefile();//判断文件是否存在
void addresult();//添加学生成绩信息
void searchresult();//查询学生成绩信息
void readresult();//加载学生成绩信息到程序
//全局变量
stmessage *head=NULL;
stscores *shead=NULL;
初级c语言学习源代码之学生管理系统
#include<stdio.h>#include<string.h>#include<stdlib.h>#define HEADLINE printf("*** Student Infomation Management System**\n")#define STD_INFO printf("\t%-10s\t%-15s\t%-5s\t%-5s\t%-11s\n","student ID","name","age","sex","telephone")char USENAME[11]= "zouxiongbo";typedef struct node{char id[10];char nm[15];int age;char sex[6];char tel[12];*next;struct node}std;std *head;int Menu_user_name(char *name){char user_name[10];printf("Please enter user name:");scanf("%s",user_name);if (strcmp(name,user_name)==0) return 0;else {printf("The user name is wrong,please enter again!\n");return 1;}}int Menu_user_pwd(char *password){char pwd[10];printf("Please enter the password:");scanf("%s",pwd);if (strcmp(pwd,password)==0) return 0;else {printf("The password is wrong,please try again!\n");return 1;} }int pwd_chng(){char a[10],b[10],pwd[10];FILE *sp;if((sp=fopen("password.txt","rw+"))==NULL){1printf("open error!\n"); exit(-1);}if(fseek(sp,3,0)==EOF){printf("seek error!\n"); exit(-1);}fgets(pwd,9,sp);rewind(sp);if(fseek(sp,3,0)==EOF){printf("seek error!\n"); exit(-1);}printf("Please enter the old password:");scanf("%s",a);if(strcmp(a,pwd)==0){printf("Please enter new password/*eight number*/:");scanf("%s",b);//strcpy(pwd,b);if(fprintf(sp,"%s\n",b)<=0){printf("fputs error! try again\n");return 1;}fclose(sp);return 0;}else {printf("old password is wrong,try again!\n");return 1;}}void info_create( ){system("clear");HEADLINE;std *sur,*prv; int i=0;int k; long int fileSize; FILE *p;prv=head=malloc(sizeof(std));memset(head,0,sizeof(std));if((p=fopen("student_info.txt","rw+"))==NULL){printf("open error!\n"); exit(-1);}fseek(p,0,SEEK_END);fileSize = ftell(p);if(fileSize==0){rewind(p);printf("No student information!\n");printf("Please enter the first number of established student information:");scanf("%d",&k);for(;i<k;++i)2{sur=malloc(sizeof(std));//memset(sur,0,sizeof(std));printf("Please followed by input student'sID/name/age/sex/tel:");scanf("%s%s%d%s%s",sur->id,sur->nm,&sur->age,sur->sex,sur-> tel);//fwrite(sur,sizeof(std),1,p);prv->next=sur;sur->next=NULL;prv=sur;sur=NULL;}fclose(p);}else{rewind(p);while(sur=malloc(sizeof(std)),fread(sur,sizeof(std),1,p)>0){//memset(sur,0,sizeof(std));/prv->next=sur;sur->next=NULL;prv=sur;sur=NULL;}fclose(p);}}void insert_student_list(std *hero){std *tmp,*kmp;int i=0;kmp=hero;while(hero->next){hero=hero->next;}tmp=malloc(sizeof(std));printf("Please followed by input student's ID/name/age/sex/tel:");scanf("%s%s%d%s%s",tmp->id,tmp->nm,&tmp->age,tmp->sex,tmp->tel);hero->next=tmp; tmp->next=NULL;//n++;}void info_brws(std *hero){system("clear");FILE *p;printf("****************************************************\n");STD_INFO; printf("\n");while(hero=hero->next)printf("\t%-10s\t%-15s\t%-5d\t%-5s\t%-11s\n",hero->id,hero-> nm,hero->age,hero->sex,hero->tel);}3int info_seek(std *hero,char *ID){while(hero=hero->next){if(strcmp(hero->id,ID)==0){printf("Your student infomation query:\n");STD_INFO;printf("\t%-10s\t%-15s\t%-5d\t%-5s\t%-11s\n",hero->id,hero->nm,hero->age,hero->sex,hero->tel);return 0;}}printf("No student's id infomation,Please check!\n");}int info_modify(std *hero){int i;char a[14];system("clear"); printf("Please select the items you want to modify! \n");printf("1:Modify name\t\t2:Modify age\n");printf("3:Modify sex\t\t4:Modify telephone\n");printf("0:Return to the previous menu\n");scanf("%d",&i);if(i==0) return 0;else { printf("Please enter student's id:");scanf("%s",a);while(hero=hero->next){if(strcmp(hero->id,a)==0){switch(i){case 1: printf("Please enter new name:");scanf("%s",a);strcpy(hero->nm,a);break;case 2: printf("Please enter new age:");scanf("%d",&i);(hero->age)=i;break;case 3: printf("Please enter new sex:");scanf("%s",a);strcpy(hero->sex,a);break;case 4: printf("Please enter new tel:");scanf("%s",a);strcpy(hero->tel,a);break;default :hero=NULL;break;}return 0;}4}printf("No student's id infomation,Please check!\n");}}int info_del(std *hero,char *ID){std *prv;for(prv = hero;hero=hero->next;prv = hero)if (strcmp(hero->id,ID)==0){prv->next = hero->next;free(hero);//n--;return 0;}printf("No student's id infomation,Please check!\n");}void info_save(std *hero){std *kmp;kmp=hero;FILE *p;if((p=fopen("student_info.txt","w"))==NULL){printf("open error!\n"); exit(-1);}while(hero=hero->next){fwrite(hero,sizeof(std),1,p);}fclose(p);while(kmp != NULL){std *tmp=kmp->next;free(kmp);kmp=tmp;}}void menu(){int i;char a[10];info_create();while(1)5{printf("******************WELCOME TO SYSTEM******************\n");printf("\n");HEADLINE;printf("\n");printf("1: Student infomation record\t2: Student information browse \n");printf("\n");printf("3: Student infomation query\t4: Student information modify\n");printf("\n");printf("5: Student infomation delete\t6: Change password\n");printf("\n");printf("0: Exit system\n");printf("\n");printf("\n");printf("****************************************************\n");//printf("No student information, please select 1 to join student information!\n");printf("Please enter number to select the funcation:\n");scanf("%d",&i);switch(i){case 1:insert_student_list(head);info_brws(head);printf("\n");break;case 2:info_brws(head);printf("\n");break;case 3:printf("Please enter the student's Id you want to seek: \n");scanf("%s",a);info_seek(head,a);printf("\n");break;case 4:info_modify(head);info_brws(head);printf("\n");break;case 5:printf("Please enter the student's Id you want to delete:\n");scanf("%s",a);info_del(head,a);info_brws(head);printf("\n");break;case 6:while(pwd_chng());system("clear");printf("Password changed successfully\n");break;case 0:info_save(head);exit(1);default: printf("enter error,select again!\n");break;}}}int main(){char user[11];FILE *p; char pwd[10];if((p=fopen("password.txt","r"))==NULL){printf("open error!\n"); exit(-1);}6if(fseek(p,3,0)==-1){printf("seek error!\n"); exit(-1);}fgets(pwd,9,p);fclose(p);strcpy(user,USENAME);//strcpy(pwd,PWD);printf("**********HOW ARE YOU!*********\n");printf("\n");printf("\n");while(Menu_user_name(user));printf("user name is OK!\n");printf("\n");while(Menu_user_pwd(pwd));system("clear");menu();return 0;}7。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
c语言学生管理系统源代码
#include <stdio.h>。
#include <stdlib.h>。
#include <string.h>。
/*定义学生结构体*/。
typedef struct student。
char num[20]; //学号。
char name[20]; //姓名。
int c; //语文成绩。
int math; //数学成绩。
float ave; //平均分。
struct student *next;。
} stu;。
/*函数声明*/。
void menu_select(); //显示菜单。
void add(); //添加学生信息。
void delete(); //删除学生信息。
void modify(); //修改学生信息。
void search(); //查询学生信息。
void get_ave(); //计算学生平均成绩。
void display(); //显示学生信息。
void esc(); //退出系统。
int main()。
menu_select();。
return 0;。
}。
//显示菜单。
void menu_select()。
int select;。
while (1)。
printf("\n学生管理系统\n");。
printf("------菜单------\n");。
printf("1.添加学生信息 2.删除学生信息\n");。
printf("3.修改学生信息 4.查询学生信息\n");。
printf("5.计算学生平均成绩 6.显示学生信息\n");。
printf("7.退出系统\n");。
printf("请输入您的选择:");。
scanf("%d", &select);。
switch (select)。
case 1:。
add();。
break;。
case 2:。
delete();。
break;。
case 3:。
modify();。
break;。
case 4:。
search();。
break;。
case 5:。
get_ave();。
break;。
case 6:。
display();。
break;。
case 7:。
esc();。
break;。
default:。
printf("输入错误,请重新输入!\n");。
menu_select();。
break;。
}。
}。
}。
//添加学生信息。
void add()。
printf("此处为添加学生信息的函数\n");。
}。
//删除学生信息。
void delete()。
printf("此处为删除学生信息的函数\n");。
}。
//修改学生信息。
void modify()。
printf("此处为修改学生信息的函数\n");。
}。
//查询学生信息。
void search()。
printf("此处为查询学生信息的函数\n");。
}。
//计算学生平均成绩。
void get_ave()。