学籍管理系统设计代码(学籍管理程序设计)
admin 发布:2022-12-19 21:23 120
本篇文章给大家谈谈学籍管理系统设计代码,以及学籍管理程序设计对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
学生学籍管理系统c语言代码(急需,致谢!)
这是一个职工管理系统,自己把名称改一改就行了
#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();
}
学籍管理系统代码
一学籍管理系统代码?
要求是:1.输入若干(20)条记录(包括学号、名字、科目、科目成绩、学期学分)2、显示所有记录3、按学号排序4、插入一条记录5、查找并显示一条记录6、按名字查找并显示一条记录7、
用C++实现一个简易的高校学籍管理系统。
#includeiostream.h
#includeiomanip.h
class list //建学生链表类
{
public:
int num,score;
char name[10];
class list *next;
};
typedef class list node;
typedef node *link;
link r,head,s; //声明头指针、工作指针、新结点指针
void create() //创建单链表
{
link p;
s=new node; //建立新节点,用s指针指向她
cout"请输入学号:"; // 输入节点内容
cins-num ;
cout"请输入姓名:";
cins-name ;
cout"请输入学分:";
cins-score ;
s-next=NULL;
if(!head-next)
head-next=s;
else
{
p=head-next;
while(p-next)
p=p-next;
p-next=s;
}
}
void linklist() //遍历单链表
{
link q=head-next;
if(!q)
cout"没有学生信息!"endl;
{
while(q)
{
cout"学号:"q-numsetw(8);
cout"姓名:"q-namesetw(8);
cout"成绩:"q-scoreendl;
q=q-next ;
}
}
}
void show_node(link q)
{
cout"学号:"q-numsetw(8);
cout"姓名:"q-namesetw(8);
cout"成绩:"q-scoreendl;
}
link search_node(int num) //学号查找
{
link q=head-next;
while(q)
{
if(q-num==num)
return q;
else
q=q-next ;
}
return NULL;
}
void delete_node(int num)
{
link p=head,q=head-next;
while(q)
{
if(q-num==num)
{
p-next=q-next;
delete q;
q=NULL;
}
else
{
p=q;
q=q-next ;
}
}
}
void modify_name(char a[],char b[])
{
for(int i=0;i10;i++)
a[i]=b[i];
}
void modify(int num,link p)
{
link q=head-next;
while(q)
{
if(q-num==num)
{
q-num=p-num;
modify_name(q-name,p-name);
q-score=p-score;
break;
}
else
q=q-next ;
}
}
void main()
{
head=new node; //建立头指针
head-next=NULL;
cout"1、添加学生信息"endl;
cout"2、显示学生信息"endl;
cout"3、查询学生信息"endl;
cout"4、修改学生信息"endl;
cout"5、删除学生信息"endl;
int choice;
while(true)
{
cout"输入您的命令代号:";
cinchoice;
switch(choice)
{
case 1:create();break;
case 2:
{
cout"学生信息为:"endl;
linklist();
};break;
case 3:{
int code;
link q=NULL;
cout"输入要查询的学号:";
cincode;
q=search_node(code);
if(!q)
cout"您查找的学生不存在!"endl;
else
{
cout"查找结果为:"endl;
show_node(q);
}
};break;
case 4:{
int code;
link q=NULL;
cout"输入要修改的学生学号:";
cincode;
q=search_node(code);
if(!q)
cout"您查找的学生不存在!"endl;
else
{
link p=new node;
p-num=code;
cout"输入新的信息:"endl;
cout"姓名:";
cinp-name;
cout"学分:";
cinp-score;
modify(q-num,p);
cout"修改后的学生信息为:"endl;
show_node(p);
}
};break;
case 5:{
int code;
link q=NULL;
cout"输入要删除的学号:";
cincode;
q=search_node(code);
if(!q)
cout"您要删除的学生不存在!"endl;
else
{
delete_node(q-num);
cout"删除后的结果为:"endl;
linklist();
}
};break;
}
}
}
学生学籍信息管理系统设计--C语言程序
#include stdio.h
#include malloc.h
#define NULL 0
#define LEN sizeof(struct student)
struct student
{long num;
int score; struct student *next;
};
int n;
struct student *creat()
{ struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=( struct student*) malloc(LEN);
scanf("%ld,%d",p1-num,p1-score);
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("%ld,%d",p1-num,p1-score);
}
p2-next=NULL;
return(head);
}
void print(struct student *head)
{ struct student *p;
printf("\nNow,These %d records are:\n",n);
p=head;
if(head!=NULL)
do
{ printf("%ld %d\n",p-num,p-score);
p=p-next;
}while(p!=NULL);
}
struct student *del(struct student *head,long num)
{ struct student *p1,*p2;
if (head==NULL){printf("\nlist null!\n");goto end;}
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("delete:%ld\n",num);
n=n-1;
}
else printf("%ld not been found!\n",num);
end:
return(head);
}
struct student *insert(struct student *head, struct student *stud)
{ struct student *p0,*p1,*p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0; p0-next=NULL;}
else
{
我这个是在网上找的,但是这个好像没写完,不知道有没谁能把它补充出来
学籍管理系统设计代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于学籍管理程序设计、学籍管理系统设计代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:.net代码行数(java代码行数)
- 下一篇:曲线统计源代码(统计曲线怎么做)
相关推荐
- 05-18关键词优化设计,关键词优化简易
- 05-14长沙设计优化公司,长沙设计优化公司招聘信息
- 05-14网站怎么设计,网站怎么设计怎么实现的
- 05-09网页代码,网页代码快捷键
- 05-08网站设计的好处,设计网站的目的
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接