资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

c语言学籍管理系统函数 c语言程序设计学籍管理系统

学生学籍管理系统c语言代码(急需,致谢!)

这是一个职工管理系统,自己把名称改一改就行了

成都创新互联是创新、创意、研发型一体的综合型网站建设公司,自成立以来公司不断探索创新,始终坚持为客户提供满意周到的服务,在本地打下了良好的口碑,在过去的10年时间我们累计服务了上千家以及全国政企客户,如成都火锅店设计等企业单位,完善的项目管理流程,严格把控项目进度与质量监控加上过硬的技术实力获得客户的一致称扬。

#includestdio.h

#includeconio.h

#includemalloc.h

#includestring.h

typedef struct ZHIGONG

{

char zhigongNumber[10];/*职工号*/

char zhigongName[20];/*职工姓名*/

char zhigongsex[4]; /*职工性别*/

char zhigongage[10]; /*出生年月*/

char zhigongedu[10];/*学历*/

char zhigongposition[30]; /*职务*/

char zhigongwage[1000]; /*工资*/

struct ZHIGONG *next;

}ZHIGONG;

ZHIGONG *headLink;/*链表表头指针*/

/*以下是函数声明*/

void ReadInfoFormFile(void);

void DesplayMenu(void);

void CreateHeadLink(void);

ZHIGONG *MallocNode(void);

void GetInformation(ZHIGONG *t);

void InsertOneNode(ZHIGONG *t);

void DesplayInfoByzhigongwage(void);

void DesplayInfoByezhigongedu(void);

void DesplayOneNode(ZHIGONG *t);

void DeleteNodeByzhigongNumber(void);

void OutputInformation(void);

void ChangeMarkByzhigongName(void);

void CompositorByTotalzhigongwage(void);

void CompositorByTotalzhigongedu(void);

void SaveLinkToFile(void);

int choose;/*用于接受用户的选择*/

/*主函数*/

void main()

{

CreateHeadLink();

ReadInfoFormFile();

DesplayMenu();

SaveLinkToFile();

}

/************************************

函数功能:从文件中读职工信息到链表中

************************************/

void ReadInfoFormFile(void)

{

FILE *fp;

ZHIGONG *p;

fp=fopen("zhigong.txt","r");

if(!fp)

{

printf("文件不存在\n");

return;

}

p=MallocNode();

while(fscanf(fp,"%s%s%s%s%s%s%s",p-zhigongNumber,p-zhigongName,p-zhigongsex,

p-zhigongage,p-zhigongedu,p-zhigongposition,p-zhigongwage))

{

InsertOneNode(p);

p=MallocNode();

}

fclose(fp);

}

/************************************

函数功能:显示菜单,根据用户的输入

完成相应的功能

************************************/

void DesplayMenu(void)

{

ZHIGONG *p;

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("| 9 退出 |\n\n");

scanf("%d",choose);/*取得用户的选择*/

switch(choose)

{

case 1:

p=MallocNode();/*先申请一个新结点*/

GetInformation(p);/*要求用户输入信息到新结点中*/

InsertOneNode(p);/*将新结点加到链表中*/

break;

case 2:

OutputInformation();/*显示所有职工的信息*/

break;

case 3:

DesplayInfoByzhigongwage();/*根据用户输入的职工工资显示该职工的信息*/

break;

case 4:

DesplayInfoByezhigongedu(); /*根据用户输入的职工学历显示该职工的信息*/

break;

case 5:

CompositorByTotalzhigongwage();/* 按工资排序*/

break;

case 6:

CompositorByTotalzhigongedu();/* 按学历排序*/

break;

case 7:

DeleteNodeByzhigongNumber();/*根据用户输入的职工号删除该职工信息*/

break;

case 8:

ChangeMarkByzhigongName();/*根据用户输入的职工姓名修改该职工信息*/

break;

case 9:

SaveLinkToFile();/*保存数据后再退出*/

free(headLink);

default:

break;

}

DesplayMenu();/*递归调用*/

}

/************************************

函数功能:建立链表表头

************************************/

void CreateHeadLink(void)

{

ZHIGONG *p;

p=(ZHIGONG*)malloc(sizeof(ZHIGONG));

headLink=p;

p-next=NULL;

}

/****************************************

函数功能:申请一个新结点,并将其初始化

*****************************************/

ZHIGONG *MallocNode(void)

{

ZHIGONG *p;

int i;

p=(ZHIGONG*)malloc(sizeof(ZHIGONG));

if(p==NULL)

return NULL;

for(i=0;i10;i++)

p-zhigongNumber[i]='\0';

for(i=0;i20;i++)

p-zhigongName[i]='\0';

for(i=0;i4;i++)

p-zhigongsex[i]='\0';

for(i=0;i10;i++)

p-zhigongage[i]='\0';

for(i=0;i10;i++)

p-zhigongedu[i]='\0';

for(i=0;i30;i++)

p-zhigongposition[i]='\0';

for(i=0;i1000;i++)

p-zhigongwage[i]='\0';

p-next=NULL;

return p;

}

/************************************

函数功能:取得用户输入的职工信息

************************************/

void GetInformation(ZHIGONG *t)

{

printf("请输入职工号:\n");

scanf("%s",t-zhigongNumber);

printf("请输入职工姓名:\n");

scanf("%s",t-zhigongName);

printf("请输入职工性别:\n");

scanf("%s",t-zhigongsex);

printf("请输入职工出生年月:\n");

scanf("%s",t-zhigongage);

printf("请输入职工学历:\n");

scanf("%s",t-zhigongedu);

printf("请输入职工职位:\n");

scanf("%s",t-zhigongposition);

printf("请输入职工工资:\n");

scanf("%s",t-zhigongwage);

}

/************************************

函数功能:在链表的结尾处增加一个结点

************************************/

void InsertOneNode(ZHIGONG *t)

{

ZHIGONG *p;

p=headLink;

while(p-next)

{

p=p-next;

}

p-next=t;

}

/*************************************************

函数功能:根据用户输入的职工工资显示该职工的信息

**************************************************/

void DesplayInfoByzhigongwage(void)

{

ZHIGONG *p;

char zhigongwage[1000];

char flag=0;

p=headLink-next;

printf("请输入职工的工资:\n");

scanf("%s",zhigongwage);

while(p)

{

if(strcmp(p-zhigongwage,zhigongwage)==0)

{

printf("职工号\t姓名\t性别\t出生年月\t学历\t职务\t工资\n\n");

DesplayOneNode(p);

flag=1;

break;

}

p=p-next;

}

if(!flag)

printf("对不起,不存在工资为%s的职工\n",zhigongwage);

}

/************************************************

函数功能:根据用户输入的职工学历显示该职工的信息

*************************************************/

void DesplayInfoByezhigongedu(void)

{

ZHIGONG *p;

char zhigongedu[10];

char flag=0;

p=headLink-next;

printf("请输入职工学历:\n");

scanf("%s",zhigongedu);

while(p)

{

if(strcmp(p-zhigongedu,zhigongedu)==0)

{

printf("职工号\t姓名\t性别\t出生年月\t学历\t职务\t工资\n\n");

DesplayOneNode(p);

flag=1;

break;

}

p=p-next;

}

if(!flag)

printf("对不起,不存在学历为 %s 的职工\n",zhigongedu);

}

/************************************

函数功能:输出一个结点的信息

************************************/

void DesplayOneNode(ZHIGONG *t)

{

printf("%s\t",t-zhigongNumber);

printf("%s\t",t-zhigongName);

printf("%s\t",t-zhigongsex);

printf("%s\t",t-zhigongage);

printf("%s\t",t-zhigongedu);

printf("%s\t",t-zhigongposition);

printf("%s\t\n",t-zhigongwage);

}

/*************************************************

函数功能:根据用户输入的职工号删除该职工的信息

**************************************************/

void DeleteNodeByzhigongNumber(void)

{

char zhigongNumber[10];

ZHIGONG *p,*q;

char flag=0;

printf("请输入要删除的职工的职工号:");

scanf("%s",zhigongNumber);

p=headLink;

q=headLink-next;

while(q)

{

if(strcmp(q-zhigongNumber,zhigongNumber)==0)

{

p-next=q-next;

free(q);

flag=1;

break;

}

p=p-next;

q=q-next;

}

if(!flag)

{

printf("不存在该职工号的职工\n");

return;

}

printf("成功删除\n");

}

/************************************

函数功能:显示所有职工的信息

************************************/

void OutputInformation(void)

{

ZHIGONG *p;

p=headLink-next;

if(p==NULL)

{

printf("现在没有职工信息,请先输入职工信息\n\n");

return;

}

printf("职工号\t姓名\t性别\t出生年月\t学历\t职务\t工资\n\n");

while(p)

{

DesplayOneNode(p);

p=p-next;

}

}

/*********************************************

函数功能:根据输入的职工姓名修改员工的信息

**********************************************/

void ChangeMarkByzhigongName(void)

{

ZHIGONG *p;

char zhigongName[10];

char flag=0;

char zhigongedu,zhigongwage,zhigongage,zhigongNumber,zhigongsex,zhigongposition;

p=headLink-next;

printf("请输入职工姓名:\n");

scanf("%s",zhigongName);

while(p)

{

if(strcmp(p-zhigongName,zhigongName)==0)

{

printf("请输入新的职工号:\n");

scanf("%s",zhigongNumber);

printf("请输入新的学历:\n");

scanf("%s",zhigongedu);

printf("请输入新的工资:\n");

scanf("%s",zhigongwage);

printf("请输入新的出生年月:\n");

scanf("%s",zhigongage);

printf("请输入新的性别:\n");

scanf("%s",zhigongsex);

printf("请输入新的职位:\n");

scanf("%s",zhigongposition);

strcpy(p-zhigongposition,zhigongposition);

strcpy(p-zhigongsex,zhigongsex);

strcpy(p-zhigongNumber,zhigongNumber);

strcpy(p-zhigongedu,zhigongedu);

strcpy(p-zhigongwage,zhigongwage);

strcpy(p-zhigongage,zhigongage);

flag=1;

printf("修改成功\n");

break;

}

p=p-next;

}

if(!flag)

printf("对不起,不存在姓名为 %s 的职工\n",zhigongName);

}

/************************************

函数功能:保存链表数据到文件中

************************************/

void SaveLinkToFile(void)

{

ZHIGONG *p;

FILE *fp;

p=headLink-next;

if(p==NULL)

{

printf("现在没有职工信息,请先输入职工信息\n\n");

return;

}

fp=fopen("zhigong.txt","w+");

if(!fp)

{

printf("文件不存在\n");

return;

}

while(p)

{

fprintf(fp,"%s%s%s%s%s%s%s",p-zhigongNumber,p-zhigongName,p-zhigongsex,

p-zhigongage,p-zhigongedu,p-zhigongposition,p-zhigongwage);

p=p-next;

}

fclose(fp);

}

/************************************

函数功能:按职工工资排序

************************************/

void CompositorByTotalzhigongwage(void)

{

ZHIGONG exchange,*r,*p,*q;

r=headLink-next;

if(r==NULL)

{

printf("现在还没职工信息,请先输入职工信息\n");

return;

}

while(r)/*两层while循环实现排序*/

{

p=r;

q=r-next;

while(q)

{

if((p-zhigongwage)(p-zhigongwage))

{

strcpy(exchange.zhigongNumber,q-zhigongNumber);/*先复制q结点信息到exchange*/

strcpy(exchange.zhigongName,q-zhigongName);

strcpy(exchange.zhigongsex,q-zhigongsex);

strcpy(exchange.zhigongage,q-zhigongage);

strcpy(exchange.zhigongedu,q-zhigongedu);

strcpy(exchange.zhigongposition,q-zhigongposition);

strcpy(exchange.zhigongwage,q-zhigongwage);

strcpy(q-zhigongNumber,p-zhigongNumber);/*再复制p结点信息到q*/

strcpy(q-zhigongName,p-zhigongName);

strcpy(q-zhigongsex,p-zhigongsex);

strcpy(q-zhigongage,p-zhigongage);

strcpy(q-zhigongedu,p-zhigongedu);

strcpy(q-zhigongposition,p-zhigongposition);

strcpy(q-zhigongwage,p-zhigongwage);

strcpy(p-zhigongNumber,exchange.zhigongNumber);/*最后复制exchange结点信息到p*/

strcpy(p-zhigongName,exchange.zhigongName);

strcpy(p-zhigongsex,exchange.zhigongsex);

strcpy(p-zhigongage,exchange.zhigongage);

strcpy(p-zhigongedu,exchange.zhigongedu);

strcpy(p-zhigongposition,exchange.zhigongposition);

strcpy(p-zhigongwage,exchange.zhigongwage);

}

q=q-next;

}

r=r-next;

}

OutputInformation();

}

/************************************

函数功能:按职工学历排序

************************************/

void CompositorByTotalzhigongedu(void)

{

ZHIGONG exchange,*r,*p,*q;

r=headLink-next;

if(r==NULL)

{

printf("现在还没职工信息,请先输入职工信息\n");

return;

}

while(r)/*两层while循环实现排序*/

{

p=r;

q=r-next;

while(q)

{

if((q-zhigongedu)(p-zhigongedu))

{

strcpy(exchange.zhigongNumber,q-zhigongNumber);/*先复制q结点信息到exchange*/

strcpy(exchange.zhigongName,q-zhigongName);

strcpy(exchange.zhigongsex,q-zhigongsex);

strcpy(exchange.zhigongage,q-zhigongage);

strcpy(exchange.zhigongedu,q-zhigongedu);

strcpy(exchange.zhigongposition,q-zhigongposition);

strcpy(exchange.zhigongwage,q-zhigongwage);

strcpy(q-zhigongNumber,p-zhigongNumber);/*再复制p结点信息到q*/

strcpy(q-zhigongName,p-zhigongName);

strcpy(q-zhigongsex,p-zhigongsex);

strcpy(q-zhigongage,p-zhigongage);

strcpy(q-zhigongedu,p-zhigongedu);

strcpy(q-zhigongposition,p-zhigongposition);

strcpy(q-zhigongwage,p-zhigongwage);

strcpy(p-zhigongNumber,exchange.zhigongNumber);/*最后复制exchange结点信息到p*/

strcpy(p-zhigongName,exchange.zhigongName);

strcpy(p-zhigongsex,exchange.zhigongsex);

strcpy(p-zhigongage,exchange.zhigongage);

strcpy(p-zhigongedu,exchange.zhigongedu);

strcpy(p-zhigongposition,exchange.zhigongposition);

strcpy(p-zhigongwage,exchange.zhigongwage);

}

q=q-next;

}

r=r-next;

}

OutputInformation();

}

C语言编程 学籍管理系统

#includestdio.h /*I/O函数*/

#includestdlib.h /*其它说明*/

#includestring.h /*字符串函数*/

#define BUFLEN 100 /* 缓冲区最大字符数 */

#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]; /* 电子邮件地址 */

}stu[N];

int k=1,n,m; /* 定义全局变量 */

void readfile();/* 函数声明 */

void seek();

void modify();

void insert();

void del();

void display();

void save();

void menu();

int main()

{

while(k)

menu();

system("pause");

return 0;

}

void help()

{

printf("\n0.欢迎使用系统帮助!\n");

printf("\n1.进入系统后,先刷新学生信息,再查询;\n");

printf("\n2.按照菜单提示键入数字代号;\n");

printf("\n3.增加学生信息后,切记保存按7;\n");

printf("\n4.谢谢您的使用!\n");

}

void readfile()/* 建立信息 */

{

char *p="student.txt";

FILE *fp;

int i=0;

if ((fp=fopen("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",stu[i].code,stu[i].name,stu[i].age,

stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail)==8)

{

i++;

i=i;

}

fclose(fp);

n=i;

printf("录入完毕!\n");

}

void seek() /*查找*/

{

int i,item,flag;

char s1[21]; /* 以姓名和学号最长长度+1为准 */

printf("------------------\n");

printf("-----1.按学号查询-----\n");

printf("-----2.按姓名查询-----\n");

printf("-----3.退出本菜单-----\n");

printf("------------------\n");

while(1)

{

printf("请选择子菜单编号:");

scanf("%d",item);

flag=0;

switch(item)

{

case 1:

printf("请输入要查询的学生的学号:\n");

scanf("%s",s1);

for(i=0;in;i++)

if(strcmp(stu[i].code,s1)==0)

{

flag=1;

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);

}

if(flag==0)

printf("该学号不存在!\n"); break;

case 2:

printf("请输入要查询的学生的姓名:\n");

scanf("%s",s1);

for(i=0;in;i++)

if(strcmp(stu[i].name,s1)==0)

{

flag=1;

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);

}

if(flag==0)

printf("该姓名不存在!\n"); break;

case 3:return;

default:printf("请在1-3之间选择\n");

}

}

}

void modify() /*修改信息*/

{

int i,item,num;

char sex1[3],s1[LEN+1],s2[LEN+1]; /* 以姓名和学号最长长度+1为准 */

printf("请输入要要修改的学生的学号:\n");

scanf("%s",s1);

for(i=0;in;i++)

if(strcmp(stu[i].code,s1)==0) /*比较字符串是否相等*/

num=i;

printf("------------------\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");

while(1)

{

printf("请选择子菜单编号:");

scanf("%d",item);

switch(item)

{

case 1:

printf("请输入新的姓名:\n");

scanf("%s",s2);

strcpy(stu[num].name,s2); break;

case 2:

printf("请输入新的年龄:\n");

scanf("%d",stu[num].age);break;

case 3:

printf("请输入新的性别:\n");

scanf("%s",sex1);

strcpy(stu[num].sex,sex1); break;

case 4:

printf("请输入新的出生年月:\n");

scanf("%s",s2);

strcpy(stu[num].time,s2); break;

case 5:

printf("请输入新的地址:\n");

scanf("%s",s2);

strcpy(stu[num].add,s2); break;

case 6:

printf("请输入新的电话号码:\n");

scanf("%s",s2);

strcpy(stu[num].tel,s2); break;

case 7:

printf("请输入新的E-mail地址:\n");

scanf("%s",s2);

strcpy(stu[num].mail,s2); break;

case 8:return;

default:printf("请在1-8之间选择\n");

}

}

}

void sort()/*按学号排序*/

{

int i,j,*p,*q,s;

char temp[10];

for(i=0;in-1;i++)

{

for(j=n-1;ji;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() /*插入函数*/

{

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;ji;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);

if(flag==0)

{

i=i;

i++;

}

}

while(in+m);

n+=m;

printf("录入完毕!\n\n");

sort();

}

void del()

{

int i,j,flag=0;

char s1[LEN+1];

printf("请输入要删除学生的学号:\n");

scanf("%s",s1);

for(i=0;in;i++)

if(strcmp(stu[i].code,s1)==0)

{

flag=1;

for(j=i;jn-1;j++)

stu[j]=stu[j+1];

}

if(flag==0)

printf("该学号不存在!\n");

if(flag==1)

{

printf("删除成功,显示结果请选择菜单6\n");

n--;

}

}

void display()

{

int i;

printf("所有学生的信息为:\n");

printf("学生学号 学生姓名 年龄 性别 出生年月 地址 电话 E-mail\n");

printf("--------------------------------------------------------------------\n");

for(i=0;in;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);

}

}

void save()

{

int i;

FILE *fp;

fp=fopen("student.txt","w"); /*写入*/

for(i=0;in;i++)

{

fprintf(fp,"%s %s %d %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);

}

fclose(fp);

}

void menu()/* 界面 */

{

int num;

printf("*********************系统功能菜单************************ \n");

printf("友情提醒:查询前请先刷新系统! \n");

printf(" ---------------------- ---------------------- \n");

printf(" ********************************************* \n");

printf(" * 0.系统帮助及说明 * * 1.刷新学生信息 * \n");

printf(" ********************************************* \n");

printf(" * 2.查询学生信息 * * 3.修改学生信息 * \n");

printf(" ********************************************* \n");

printf(" * 4.增加学生信息 * * 5.按学号删除信息 * \n");

printf(" ********************************************* \n");

printf(" * 6.显示当前信息 * * 7.保存当前学生信息* \n");

printf(" ********************** ********************** \n");

printf(" * 8.退出系统 * \n");

printf(" ********************** \n");

printf(" ---------------------- ---------------------- \n");

printf("请选择菜单编号:");

scanf("%d",num);

switch(num)

{

case 0:help();break;

case 1:readfile();break;

case 2:seek();break;

case 3:modify();break;

case 4:insert();break;

case 5:del();break;

case 6:display();break;

case 7:save();break;

case 8:k=0;break;

default:printf("请在0-8之间选择\n");

}

C语言课程设计----学生学籍管理系统 急急急 来大神~

#includestdio.h

#includestring.h

#includestdlib.h

typedef struct stud //学生信息结构

{

long num;

char name[20];

float score;

}Stud;

typedef struct node

{

Stud student;

struct node *next;

}Node;

Node *head=NULL;

void read(void);

void inser(long b);

void print();

void find(long b);

void searchname(char *s);

Node * del(long n);

void sort(int flag);

void menu();

void main()

{

char choose;

int flag=1;

while (flag)

{

menu(); //调用功能菜单函数,显示菜单项。

printf(" 请选择:");

choose=getchar();

switch(choose)

{

case '1':read(); //调用建立链表的函数;输出链表信息;

print();

printf("\nPress any key Continue ");

//getchar();

getchar();

break;

case '2': //调用按学号查找学生信息的函数;并输出查找结果信息;

long c;

printf("input the number you want to find:");

scanf("%ld",c);

find(c);

printf("\nPress any key Continue.");

getchar();

break;

case '3':

//调用按姓名查找学生信息的函数;并输出查找结果信息;

char s[20];

printf("input the name you want to find:");

scanf("%s",s);

searchname(s);

printf("\n Press any key Continue.");

getchar();

getchar();

break;

case '4':

//调用根据学号删除某个学生信息的函数;并输出删除后的链表信息;

Node *h;

long n;

printf("input the number you want to delete:");

scanf("%ld",n);

h=del(n);

if(h==NULL) printf("No find the student \n");

else print();

printf("\n Press any key Continue.");

getchar();

getchar();

break;

case '5':

//调用插入新的学生信息的函数;并输出插入后的链表信息;

long a;

printf("input the number for the new:\n");

scanf("%ld",a);

inser(a);

print();

printf("\n Press any key Continue.");

getchar();

getchar();

break;

case '6':

//调用按分数降序排序输出的函数;并输出排序后的链表信息;

sort(1);

print();

sort(0);

printf("\nPress any key Continue.");

getchar();

getchar();

break;

case '0':

//结束程序运行!

flag=0;

printf("\n *** The End! ***\n");

break;

default: printf("\n Wrong Selection !(选择错误,重选)\n");

getchar();

}

}

}

void menu() //综合作业功能菜单

{

printf(" \n 学 生 信 息 管 理 系 统\n");

printf(" \n 菜 单\n\n");

printf(" \n 1. 建 立 链 表 并 显 示 \n");

printf(" \n 2. 查 找 某 学 号 的 学 生 信 息 \n");

printf(" \n 3. 查 找 某 姓 名 的 学 生 信 息 \n");

printf(" \n 4. 删 除 某 个 学 号 的 学 生\n");

printf(" \n 5. 插 入 新 的 学 生 信 息 \n");

printf(" \n 6. 按 分 数 降 序 排 序 输 出 \n");

printf(" \n 0. 退 出\n\n");

}

void read(void)

{

long a;

printf("input the number:");

scanf("%ld",a);

while(a0){

inser(a);

printf("input the number:");

scanf("%ld",a);

}

}

void inser(long b)

{

Node *last,*current,*p;

current=head;

while(current!=NULLbcurrent-student.num){

last=current;

current=current-next;

}

if(current==NULL||bcurrent-student.num){

printf("input the name,score:");

p=(Node *)malloc(sizeof(Node));

p-student.num=b;

scanf("%s%f",p-student.name,p-student.score);

p-next=NULL;

if(current==head){

p-next=head;

head=p;

}

else{

p-next=current;

last-next=p;

}

}

else if(b==current-student.num)

printf("error input a different number:");

}

void print()

{

Node *p=head;

printf("学号 姓名 成绩:\n");

while(p!=NULL){

printf("%ld %s %f\n",p-student.num,p-student.name,p-student.score);

p=p-next;

}

printf("\n");

}

void find(long b)

{

Node *p=head;

while(p!=NULLb!=p-student.num)

p=p-next;

if(!p) printf("No found\n");

else {

printf("学号 姓名 成绩\n");

printf("%ld %s %f\n",p-student.num,p-student.name,p-student.score);

}

}

void searchname(char *s)

{

Node *p=head;

int flag=0;

printf("学号 姓名 成绩:\n");

while(p!=NULL)

{

if(strcmp(p-student.name,s)==0)

{

printf("%ld %s %f\n",p-student.num,p-student.name,p-student.score);

flag=1;

p=p-next;

continue;

}

else p=p-next;

}

if(!flag) printf("No find");

}

Node * del(long n)

{

Node *p=head,*last;

while(p-student.num!=n){

last=p;

p=p-next;

}

if(p==NULL) return p;

else if(p==head) head=p-next;

else last-next=p-next;

return head;

}

void sort(int flag)

{

/*flag==1 按分数排序 else 按学号排序*/

Node *p1,*p2,*k;

float t1;

long t2;

char s[20];

for(p1=head;p1-next;p1=p1-next)

{

k=p1;

for(p2=p1-next;p2;p2=p2-next)

if(flag==1k-student.scorep2-student.score||!flagk-student.nump2-student.num)

k=p2;

if(k!=p1){

t1=p1-student.score;

p1-student.score=k-student.score;

k-student.score=t1;

t2=p1-student.num;

p1-student.num=k-student.num;

k-student.num=t2;

strcpy(s,p1-student.name);

strcpy(p1-student.name,k-student.name);

strcpy(k-student.name,s);

}

}

}

用c语言编写一个学生学籍管理系统

#includeiostream

#includestring

#includefstream

#includeiomanip

using namespace std;

class student

{

protected:

int number;

char name[20];

char sex[6];

char place[20];

char nation[6];

char birth[20];

char party[10];

char id[20];

double score[3];

public:

student *next;

student(){ }

~student(){ }

char* getname(){ return name; }

int getnumber(){ return number;}

double getscore(int i) { return score[3];}

float getg(){ return (score[0]+score[1]+score[2]); }

void input()

{

int e=1;

cout"\t\t\t按提示输入:"endl;

cout"\t\t输入编号: ";

cinnumber;

cout"\t\t输入姓名: ";

cinname;

do

{

cout"\t\t输入性别: ";

cinsex;

if(strcmp(sex,"男")==0 || strcmp(sex,"女")==0)

{

cout"\t\t输入籍贯: ";

cinplace;

cout"\t\t输入民族: ";

cinnation;

cout"\t\t输入生日: ";

cinbirth;

cout"\t\t输入政治面貌: ";

cinparty;

cout"\t\t输入身份证号: ";

cinid;

cout"\t\t输入数学分数: ";

cinscore[0];

cout"\t\t输入英语分数: ";

cinscore[1];

cout"\t\t输入计算机分数: ";

cinscore[2];

e=0;

}

else

{

cout"\t\t\t无此类型性别!重新输入!"endl;

e=1;

}

}while(e);

return ;

}

void input(ifstream is)

{

isnumbernamesexplacenationbirthpartyid

score[0]score[1]score[2];

is.get();

}

void output()

{

cout"学生基本信息如下:"endl;

cout"编号:"number

" 姓名:"name

" 性别:"sex

" 籍贯:"place

" 民族:"nation

" 生日:"birth

" 政治面貌:"partyendl

"身份证号:"id

" 数学:"score[0]

" 英语:"score[1]

" 计算机:"score[2]

" 总分:"getg()endlendl;

}

void output(ofstream os)

{

ossetw(6)number

setw(15)name

setw(6)sex

setw(20)place

setw(6)nation

setw(20)birth

setw(20)party

setw(20)id

setw(6)score[0]

setw(6)score[1]

setw(6)score[2]endl;

}

};

class school

{

public:

school(){ head=new student; head-next=NULL; key=0; }

~school(){ delete head; }

void input();

void mend();

void del();

int find(student **p,int num,char *pn="^");

void found();

void show();

void count();

void save();

void begin();

void clear();

char mainmenu();

int getkey(){ return key;}

void setkey(int k){ key=k; }

private:

student *head;

int key;

};

//录入函数

void school::input()

{

student *p,*p2=NULL;

p=head;

int n;

while(p-next)

p=p-next;

while(n)

{

p2=new student;

p2-input();

p-next=p2;

p2-next=NULL;

p=p-next;

school::setkey(1);

cout"\t\t\t按1继续,按0返回 : ";

cinn;

}

}

//子查找函数

int school::find(student **p1,int num,char *pn)

{

student *p;

p=head;

while(p-next)

{

(*p1)=p;

if( (p-next)-getnumber()==num||!strcmp( (p-next)-getname(),pn ) )

return 1;

p=p-next;

}

return 0;

}

//查找函数

void school::found()

{

student *p;

int num=-1,n=9;

char name[20]="^";

do

{

cout"\t\t1:按编号查找,2:按姓名查找: ";

cinn;

}while(n1||n2);

if(n==1)

{

cout"\t\t\t输入编号: ";

cinnum;

}

if(n==2)

{

cout"\t\t\t输入姓名: ";

cinname;

}

if(!find(p,num,name) )

{

cout"\t\t找不到你要查找的内容!"endl;

return;

}

(p-next)-output();

}

//删除函数

void school::del()

{

student *p,*p2;

int num;

cout"\t\t\t输入编号: ";

cinnum;

if( !find(p,num,"^") )

{

cout"\t\t找不到你要删除的内容!"endl;

return;

}

(p-next)-output();

p2=p-next;

p-next=p2-next;

delete p2;

school::setkey(1);

}

//显示函数

void school::show()

{

student *p;

p=head;

while(p-next)

{

(p-next)-output();

p=p-next;

}

}

//修改函数

void school::mend()

{

student *p;

int num=-1,n;

char name[20]="^";

do

{

cout"\t\t1:按编号修改,2:按姓名修改: ";

cinn;

}while(n1||n2);

if(n==1)

{

cout"\t\t\t输入编号: ";

cinnum;

}

if(n==2)

{

cout"\t\t\t输入姓名: ";

cinname;

}

if( !find(p,num,name) )

{

cout"\t\t找不到你要修改的内容!"endl;

return;

}

(p-next)-output();

(p-next)-input();

school::setkey(1);

}

//保存函数

void school::save()

{

student *p;

p=head;

ofstream os("student.txt",ios::out);

if (school::getkey()==1)

{

while(p-next)

{

(p-next)-output(os);

p=p-next;

}

}

cout"\t\t\t文件已保存! "endl;

school::setkey(0);

}

//初始化函数

void school::begin()

{

student *p,*p2;

p=head;

clear();

long t;

ifstream is("student.txt",ios::in);

if(!is)

{

ofstream os("student.txt",ios::out);

os.close();

return ;

}

int num=-1;

while(1)

{

num=-1;

t=is.tellg();

isnum;

is.seekg(t);

if(num0)

{

is.close();

return;

}

p2=new student;

p2-input(is);

p-next=p2;

p2-next=NULL;

p=p-next;

}

}

//清空函数

void school::clear()

{

student *p,*p2;

p=head-next;

while( p )

{

p2=p;

p=p-next;

delete p2;

}

}

//统计函数

void school::count()

{

student *p;

p=head;

int n=0;

double g[3]={0,0,0};

float j[3]={0,0,0};

while(p-next)

{

p=p-next;

n++;

for(int i=0;i3;i++)

{

g[++i]=g[i]+( p-getscore(i) );

(p-getscore(i) )=60? j[i++] : 0 ;

}

}

cout"\t\t\b\b\b\b数学总分:"g[0]" 平均分:"g[0]/n

" 及格率:"j[0]/nendl"\t\t\b\b\b\b英语总分:"g[1]

" 平均分:"g[1]/n" 及格率:"j[1]/nendl

"\t\t\b\b\b\b计算机总分: "g[2]" 平均分: "g[2]/n

" 及格率:"j[2]/nendl;

}

//主选菜单函数

char school::mainmenu()

{

char n[6];

cout"\n\n ☆☆☆☆欢迎进入高校学籍管理系统☆☆☆☆"endlendl

" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"endl

" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"endl

" * * 1: 录入学生信息 * *"endl

" * * 2: 显示学生信息 * *"endl

" * * 3: 查找学生信息 * *"endl

" * * 4: 删除学生信息 * *"endl

" * * 5: 修改学生信息 * *"endl

" * * 6: 统计学生成绩 * *"endl

" * * 7: 保存学生信息 * *"endl

" * * 0: 退出系统 * *"endl

" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"endl

" * * * * * * * * * * * * * * * * * * * * * * * * * * * *"endl

" 请选择:";

cinn;

return n[0];

}

//主函数

void main()

{

school pp;

int k=1;

char n;

pp.begin();

while(k==1)

{

n=pp.mainmenu();

switch(n)

{

case '1':pp.input(); break;

case '2':pp.show(); break;

case '3':pp.found(); break;

case '4':pp.del(); break;

case '5':pp.mend(); break;

case '6':pp.count(); break;

case '7':pp.save(); break;

case '0':

if(pp.getkey()==1)

{

cout"\t\t\t是否保存? 1 : 保存 0:不保存 : ";

cink;

if(k==1)

pp.save();

}

pp.clear();

k=0;

break;

}

}

}


当前文章:c语言学籍管理系统函数 c语言程序设计学籍管理系统
网页地址:http://cdkjz.cn/article/hhjpss.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220