学生成绩管理系统代码(C语言编写)

合集下载

学生管理系统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语言源程序
{
for(p=head->next;p!=NULL&&strcmp(p->name,tem);p=p->next);
if (!p)
{
printf("\n\n找不到你要查询的姓名,请重新输入,输入0表\
示结束:");
scanf("%s",tem);
}
else if (!strcmp(p->name,tem))
n=0;
head=(Student *)malloc(LEN);
p2=head;
printf("\n请输入第%d名学生的学号,学号为0表示结束输入:",n+1);
scanf("%d",&flag);
while(getchar()!='\n');
for(;flag;)
{
n++;
p1=(Student *)malloc(LEN);
char xueqi[20];
int score[4];
int sum;
struct student *next;
}Student;
int n;
Student *cin(void);
Student *sort_1(Student *head,int);
void sort_2(Student *head);
max_3=min_3=p->score[2];max_2=min_2=p->score[3];
max_sum=min_sum=p->sum;
for(;p;p=p->next)
{
if (max_1<p->score[0]) max_1=p->score[0];

C语言课程设计 200行代码 -学生成绩查询系统.doc

C语言课程设计 200行代码 -学生成绩查询系统.doc

功能:查询修改统计成绩。

#include <stdio.h>struct student /*成绩表的结构声明*/{int num;char name[15];char sex;float WuLi;float ShuXue;float YingYu;float KuaiJi;float totle;};/*定义6个学生的信息:*/#define STU_NUMBER 6 /*宏定义学生数为6*/struct student Stu[STU_NUMBER]={{101,"yuchen", 'F', 98,85,96,89,0},{102,"xiaotong", 'F', 99,91,90,93,0},{103,"likanglong",'M', 76,83,74,82,0},{104,"yinger", 'F', 88,76,89,77,0},{105,"fengjiao", 'F', 97,100,94,96,0},{106,"sunyao", 'M', 87,89,66,84,0} };int SelectMainMenu(); /*显示并选择主菜单。

返回:被选择的菜单项*//*所有的函数声明:*/void Show(); /*成绩查询模块*/void Modify(); /*成绩修改模块*/void Stat(); /*成绩统计模块*/void StatAve(float *AveWuLi,float *AveShuXue,float *AveYingYu,float *AveKuaiJi);/*统计平均分*/int FindStudent(int num); /*根据学号查找某一学生*/void SetAllTotle(); /*计算所有学生总分*/void SetTotle(int No); /*计算第No个学生总分*/void ShowAllStudent(); /*显示所有成绩*/void ShowTitle(); /*显示表头信息*/void ShowStudent(int No); /*显示第No个的学生信息*/void main(){int isend=0,password=0; /*程序结束标志量,0表示不结束,1表示结束*/SetAllTotle(); /*计算所有学生总分*/while(password!=666){printf("qing shu ru mi ma:\n");scanf("%d",&password);}{switch(SelectMainMenu()) /*显示并选择主菜单*/{case 1: /*成绩查询*/Show(); /*调用成绩查询函数*/break;case 2: /*成绩修改*/Modify(); /*调用成绩修改函数*/break;case 3: /*成绩统计*/Stat(); /*调用成绩统计函数*/break;case 4: /*退出系统*/printf("\nxie xie nin de shi yong,zai jian!\n\n");isend = 1; /*设置程序结束标志*/break;}if(isend) break; /*程序结束*/}}int SelectMainMenu() /*显示并选择主菜单。

学生绩点计算系统C语言(附完整源代码)

学生绩点计算系统C语言(附完整源代码)

学生绩点计算系统C语言(附完整源代码)本文档提供了一个用于计算学生绩点的C语言程序的完整源代码。

程序简介该程序是一个学生绩点计算系统,它可以读取学生的课程成绩和学分信息,并计算出每门课程的绩点以及整个学期的绩点。

该程序可以帮助学生快速准确地计算自己的绩点,以便了解自己在学业上的表现。

源代码以下是该程序的完整源代码:include <stdio.h>int main() {int numCourses;float totalCredits = 0;float totalGradePoints = 0;printf("请输入您的课程数量:");scanf("%d", &numCourses);for (int i = 0; i < numCourses; i++) {int credits;float grade;printf("请输入第%d门课的学分:", i + 1); scanf("%d", &credits);printf("请输入第%d门课的成绩:", i + 1); scanf("%f", &grade);totalCredits += credits; totalGradePoints += credits * grade;}float gpa = totalGradePoints / totalCredits;printf("\n您的绩点为:%.2f\n", gpa);return 0;}该程序首先会要求用户输入课程数量,然后逐一询问每门课程的学分和成绩。

程序会根据用户输入的数据计算出总学分和总绩点,并最终计算出绩点(GPA),并将结果输出。

使用方法1. 运行该程序;2. 按照提示输入课程数量;3. 按照提示逐一输入每门课程的学分和成绩;4. 程序将会输出您的绩点(GPA)。

C语言课程设计—学生成绩管理系统

C语言课程设计—学生成绩管理系统

#include ”stdio.h”#include ”string.h”#include "stdlib.h"#include "conio.h"#include ”string.h”#include "fcntl。

h"typedef struct student{int num;char grade[10];char classroom[10];char name[10];float score_math;float score_chinese;float score_english;float average;float sum;}STU;typedef struct Node{STU data;struct Node *next;}*linklist;void menu();char *loginpassword(char password[],int n);//登录验证密码函数声明//linklist createstulist(linklist head);//创建学生链表即学生信息录入函数声明// void printstulist(linklist head);//学生信息输出函数声明//void searchstu_namelist(linklist head);//学生信息查询函数声明(按姓名)// void searchstu_numlist(linklist head);//学生信息查询函数声明(按学号) linklist modifystulist(linklist head);//学生信息修改函数声明//linklist delatestulist(linklist head);//学生信息删除函数声明//void savestulist(linklist head);//学生信息保存到文件函数声明// linklist loadstulist();//从文件中读取学生信息函数声明// void sortstulist(linklist head); //成绩排名函数(按年级)声明//void sort(STU stu[],int flag); //学生分班函数声明//void sortstuclass(linklist head); //成绩排名函数(按班级)声明////*************************************//void main(){char admin[]=”zhangqiong";char password[]=”123456";char person[20];char password1[10];int i;printf(”********************************************************************************\n”);printf("\t\t **********欢迎来到学生成绩管理系统**********\n\n");printf(”********************************************************************************\n\n”);printf(”\t\t\t\t用户登录\n\n\n\n");for(i=0;i<3;i++){printf("用户名:”);gets(person);fflush(stdin);printf(”\n\n\n”);loginpassword(password1,10);printf("\n\n\n”);if(strcmp(admin,person)==0&&strcmp(password,password1)==0){printf(”\t\t\t\t成功登录,亲!\n”);printf("\n\n”);printf(”按任意键继续!”);getch();menu();break;}elseprintf("\t用户名或者密码输入错误\n”);}if(i==3)printf("\t对不起,您今天输入次数太多,已被强制退出!\n”);}//**********************************************************////**********************************************************//char *loginpassword(char password[],int n)//登录密码函数,隐藏密码可见//{int i=0;int m=0;char ch;printf("用户密码:”);while((ch=getch())!='\r’&&m〈n){password[i++]=ch;printf(”*");}password[i]='\0';return password;}//***************************************************// void menu()//主界面函数//{system("cls");linklist L;L=(linklist)malloc(sizeof(Node));L—>next=NULL;int ch;do{printf(”\t -——-----—-******——--——--—---******—————-————-******-—-—-—-—-—\n\n");printf("\t\t\t**********学生成绩管理系统***********\n\n”);printf("\t ——----——--******-—-——------—******—---———--—-******—---———-——\n\n\n\n\n");printf("\t1。

学生成绩管理系统c语言代码(供参考)

学生成绩管理系统c语言代码(供参考)

C程序学生管理系统以下是用c语言编写的学生成绩管理系统的简单代码,可以用vc运行(供参考)#include"stdio.h"#include"stdlib.h"#include"string.h"typedef struct student//定义学生{char name[10];int number;char sex[2];int math;int eglish;int clanguge;int average;}student;typedef struct unit//定义接点{student date;struct unit *next;}unit;unit* build()//建立链表并返回指针{unit *p;if((p=(unit*)malloc(sizeof(unit)))==NULL){ printf("=>初始化失败!");return 0;}else{p->next=NULL;p->date.number=0;//头结点存放学生人数printf("初始化成功!\n");return p;}}void add(unit *head)//增加学生{unit *p,*q;int m,n=0;q=head->next;p=(unit*)malloc(sizeof(unit));printf("=>请输入新生姓名!\n");gets(p->);fflush(stdin);printf("=>请输入学号!\n");while(n==0){scanf("%d",&m);fflush(stdin);if(q==NULL) n=1;while(q){if(q->date.number==m){printf("=>你输入的学号与已有同学的学号相同,请重新输入!\n");q=head->next;break;}else{q=q->next;if(q==NULL) n=1;}}}p->date.number=m;printf("=>请输入性别!\n");gets(p->date.sex);fflush(stdin);printf("=>请输入数学成绩\n");scanf("%d",&m);fflush(stdin);p->date.math=m;printf("=>请输入英语成绩\n");scanf("%d",&m);fflush(stdin);p->date.eglish=m;printf("=>请输入c语言成绩\n");scanf("%d",&m);fflush(stdin);p->date.clanguge=m;p->date.average=(p->date.math+p->date.eglish+p->date.clanguge);q=head->next;head->next=p;p->next=q;head->date.number++;}void deletion(unit *head)//删除一名学生{unit *p=head->next,*q=head;char N[10];printf("=>请输入你想删除的学生姓名!\n");gets(N);fflush(stdin);if(p==NULL)printf("=>系统无学生可删除!\n");while(p){if(strcmp(p->,N)==0){q->next=p->next;head->date.number--;printf("=>删除%s成功!\n",p->);free(p);break;}else{p=p->next;q=q->next;if(p==NULL)printf("=>你要删除的学生不存在,删除失败!\n");}}}int display(unit *head)//显示学生信息{unit *p=head->next;int m,n=0;char N[10];if(p==NULL){printf("=>系统无学生!\n");return 0;}while(n==0){printf("********************************************************* *********************\n");printf("=>请选择你的操作!\n");printf("=>\t\t\t1.显示所有\t2.按姓名查找\n\t\t\t3.按学号查找\t4.返回主菜单\n");scanf("%d",&m);fflush(stdin);switch(m){case 1:printf("\n=>该系统拥有%d名学生!\n\n",head->date.number);p=head->next;printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t综合\n\n");while(p){printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->,p->date.numb er,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);p=p->next;}break;case 2:printf("=>请输入查找姓名!\n");gets(N);fflush(stdin);p=head->next;while(p){if(strcmp(p->,N)==0){printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t 综合\n");printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->,p->date.numb er,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);break;}else{p=p->next;if(p==NULL)printf("=>你要查的学生不存在!");}}break;case 3: printf("=>请输入查找学号!\n");scanf("%d",&m);fflush(stdin);p=head->next;while(p){if(p->date.number==m){printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t 综合\n");printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->,p->date.numb er,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);break;}else{p=p->next;if(p==NULL)printf("=>你要查的学生不存在!\n");}}break;case 4:n=1;break;}}return 1;}int range(unit *head)//排序{unit *p=head,*q=head->next;int n,i,m=head->date.number;printf("********************************************************* **********************\n");printf("\t\t\t1.按学号\t2.按成绩\n\n");printf("=>请选择操作!\n》");scanf("%d",&n);fflush(stdin);if(q==NULL){ printf("=>无学生可排序!\n");return 0;}switch(n){case 2:for(i=0;i<m;i++)//按总分排序{p=head;q=head->next;while(q->next){if((q->date.average)<(q->next->date.average)){p->next=q->next;p=p->next;q->next=p->next;p->next=q;}else{p=p->next;q=q->next;}}}break;case 1:for(i=0;i<=m;i++)//按学号排序{p=head;q=head->next;while(q->next){if((q->date.number)>(q->next->date.number)){p->next=q->next;p=p->next;q->next=p->next;p->next=q;}else{p=p->next;q=q->next;}}}break;}printf("=>排序成功!\n");return 1;}void menu(){printf("\n********************************* 主菜单***************************************\n");printf("\t\t\t1.新建系统\t2.添加学生\n\t\t\t3.删除学生\t4.查看信息\n\t\t\t5.排列顺序\t6.读取信息\n\t\t\t7.保存信息\t8.退出系统\n");printf("=>请选择你的操作!\n");}int save(unit *head)//保存{FILE *fp;unit *p;p=head;if((fp=fopen("d:\\学生","wb+"))==NULL){printf("=>保存失败!");return 0;}while(p){fwrite(&(p->date),sizeof(student),1,fp);p=p->next;}printf("=>保存成功!");fclose(fp);return 1;}unit* read()//读入系统学生信息{int i;unit *p,*q,*head;FILE *fp;if((head=(unit*)malloc(sizeof(unit)))==NULL) { printf("=>开辟空间失败!");exit(1);}else{head->next=NULL;head->date.number=0;//头结点存放学生人数}q=head;if((fp=fopen("d:\\学生","rb"))==NULL){printf("=>系统无学生!\n");return 0;}fread(&(q->date),sizeof(student),1,fp);for(i=0;i<head->date.number;i++){if((p=(unit*)malloc(sizeof(unit)))==NULL){ printf("=>读值失败!");exit(1);}fread(&(p->date),sizeof(student),1,fp);p->next=q->next;q->next=p;}fclose(fp);return head;}void main(){int m=0,n, i;unit *head;printf("************************************************************* *******************\n\n");printf("\t\t\t* 欢迎使用学生成绩管理系统 * \n");printf("\n\t\t\t\t\t\t\t\t编译员:吹吹风\n\n");printf("=>正在读取系统信息......\n");if((head=read())==0){printf("=>是否新建?\n");printf("\t\t\t是(1)\t\t否(2)\n");scanf("%d",&i);fflush(stdin);if(i==1)head=build();else if(i==2)exit(1);}elseprintf("=>信息导入成功!");while(m==0){menu();scanf("%d",&n);fflush(stdin);switch(n){case 1: head=build();break;case 2:add(head);break;case 3:deletion(head);break;case 4:display(head);break;case 5: range(head);break;case 6:head=read();if(head!=0) printf("=>读取存盘成功!\n");break;case 7:save(head);break;case 8:m=1;break;}}}。

学生成绩管理系统源代码

学生成绩管理系统源代码

学生成绩管理系统源代码#include<stdio.h>#include<stdlib.h>int main(){typedef struct LNode{char name[6];int no;int yw;int sx;int yy;struct LNode *next;}LinkList;struct NameNo{int no;int yw;int sx;int total;char name[6];}st[10];FILE *fp,*fp1;char ch,sname[6];int x,i,j;NameNo tmp;LinkList *p,*s;printf("\n");printf("-------------------------------");printf("学生成绩管理系统");printf("--------------------------------");printf("\n\n");printf("在您的C盘根目录下是否有cj1.txt和cj2.txt文件?如果有请输入,1");printf("否则输入0;如果没有,那么程序将终止!1 or 0?");scanf("%d",&i);if(i==0) return 0;printf("\n\n");printf("对cj1.txt和cj2.txt进行合成请按‘1’");scanf("%d",&i);if(i!=1) return 0;printf("正在把cj1.txt和cj2.txt中的数据进行合并\n");printf("......\n.....\n....\n...\n..\n.\n");if((fp=fopen("c:\\cj1.txt","rt"))==NULL){printf("无cj1.txt文本文件,程序结束。

c++语言学生成绩管理系统源代码

c++语言学生成绩管理系统源代码

我是电大的学生,这是struct 类型的c 语言学生成绩管理系统代码,大家交流一下#include<stdio.h>#include<string.h> #include<stdlib.h>#define MAXN 100 //#define MAXN 100 //一个班最多的人数一个班最多的人数#define MAXM 2 //#define MAXM 2 //成绩的课程门数成绩的课程门数int R;void input(); //1.void input(); //1.学生成绩新建学生成绩新建void sort(); //2.void sort(); //2.学生成绩插入学生成绩插入void load(); //3.void load(); //3.学生成绩修改学生成绩修改void print(); //4.void print(); //4.学生成绩删除学生成绩删除void total(); //5.void total(); //5.学生成绩统计学生成绩统计void search(); //6.void search(); //6.学生成绩查询学生成绩查询void save(); //7.void save(); //7.学生成绩保存学生成绩保存void end(); //8.void end(); //8.结束结束struct student{char name[20]; //char name[20]; //保存全班姓名保存全班姓名保存全班姓名char num[12]; // char num[12]; //保存全班学号保存全班学号保存全班学号char man[20]; //char man[20]; //保存全班性别保存全班性别保存全班性别float score[MAXM]; //float score[MAXM]; //保存全班所有课程成绩保存全班所有课程成绩保存全班所有课程成绩 float sum; //float sum; //保存全班每个人的总成绩保存全班每个人的总成绩保存全班每个人的总成绩float avg; // float avg; //保存每个人的平均成绩保存每个人的平均成绩保存每个人的平均成绩};struct student s[MAXN];struct http{char subject[20]; //char subject[20]; //保存全班所有课程保存全班所有课程保存全班所有课程};struct http c[MAXM];void main() //void main() //欢迎首界面欢迎首界面欢迎首界面{ int select,l;system("color fC");printf("\n");printf("\n");printf("\n");printf("\n");printf(" printf(" ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥\n"); \n"); printf(" * *\n"); printf(" * *\n"); printf(" * printf(" * 欢迎进入终极一班学生管理系统欢迎进入终极一班学生管理系统欢迎进入终极一班学生管理系统 *\n"); *\n"); printf(" * *\n"); printf(" * ︻┳═一︻┳═一︻┳═一 cf ... *\n"); cf ... *\n"); printf(" * printf(" * ┈━═☆甘总管的多塔生活∝╬══→┈━═☆甘总管的多塔生活∝╬══→┈━═☆甘总管的多塔生活∝╬══→ *\n"); *\n"); printf(" * *\n"); printf(" * printf(" * 凸凸^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸凸凸凸凸^-^^-^^-^凸凸 *\n"); printf(" printf(" ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥\n"); \n"); printf(" printf(" ╭ ╭ ╭ v v v╮╮ ╔══╗╔╗╔══╗╔╗ ╔╗╔╗╔╗╔╗╔╗╔╗ ╭╭''''''╮╮\n");printf(" (@ ^o^ @)╚╗╔╝║║╔═╦╦╦═╗║╚╝╠═╦╦╗(~ : : ~~)\n");printf(" (~) : (~)╔╝╚╗║╚╣║║║║╠╣╚╗╔╣║║║║(~) v (~)\n");printf(" ╚══╝╚═╩═╩═╩═╝ ╚╝╚═╩═╝ \n");printf("\n");printf("\n");printf(" printf(" 请按任意键进入下一界面请按任意键进入下一界面请按任意键进入下一界面\n"); \n");printf("------------------------------------------------------------------\n"); system("pause");system("color f2");system("color f1");system("color f3"); system("color fE");system("color fB");system("color f5");system("color f9");system("color f6");system("color f1");system("color f3");system("color fE");system("color fB");system("color f5");system("color f9"); system("color f6");system("color f1");system("color f3");system("color f5");system("color f9");system("color f6");system("color fD");system("pause");system("color fC");system("cls"); // system("cls"); //上面是第一个界面上面是第一个界面上面是第一个界面while(1){system("cls");printf(" ****************欢迎进入终极一班学生管理系统****************\n");printf(" ******************************************************\n");printf(" * ∝╬══→ 1.学生成绩新建 囧rz 欢 *\n");printf(" * ::======>> 2. 2.学生成绩插入学生成绩插入学生成绩插入 迎迎 *\n"); printf(" * printf(" * ┈━═☆┈━═☆┈━═☆ 3. 3.学生成绩修改学生成绩修改学生成绩修改 来来 *\n"); printf(" * printf(" * ∝╬══→∝╬══→∝╬══→ 4. 4.学生成绩删除学生成绩删除学生成绩删除 到到 *\n"); printf(" * ∝╬══→∝╬══→ 5. 5.学生成绩统计学生成绩统计学生成绩统计 英英 *\n"); printf(" * printf(" * ∝╬══→∝╬══→∝╬══→ 6. 6.学生成绩查询学生成绩查询学生成绩查询 雄雄 *\n"); printf(" * printf(" * ▄︻┻═┳▄︻┻═┳▄︻┻═┳ 7. 7.学生成绩保存学生成绩保存学生成绩保存 联联 *\n"); printf(" * printf(" * ∝╬══→∝╬══→∝╬══→ 8. 8.退出退出退出//撒拉嘿撒拉嘿 盟盟 *\n"); printf(" * ( printf(" * (⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙)()()(⊙_⊙⊙_⊙⊙_⊙) *\n"); ) *\n");printf(" ******************************************************\n"); printf("\n"); printf("\n printf("\n"); printf("\n 请输入您的选择编号请输入您的选择编号请输入您的选择编号,,回车键继续:回车键继续:\n"); \n");printf("---------------------------------------------------------------------------\n"); scanf("%d",&select);do {if(select<1||select>8){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&select);}l=select;}while(l<1||l>8);switch(select) {case 1:input();break; //1. case 1:input();break; //1.学生成绩新建学生成绩新建学生成绩新建case 2:sort(); break; //2. case 2:sort(); break; //2.学生成绩插入学生成绩插入学生成绩插入case 3:load(); break; //3. case 3:load(); break; //3.学生成绩修改学生成绩修改学生成绩修改case 4:print(); break; //4. case 4:print(); break; //4.学生成绩删除学生成绩删除学生成绩删除case 5:total();break; //5. case 5:total();break; //5.学生成绩统计学生成绩统计学生成绩统计case 6:search();break; //6. case 6:search();break; //6.学生成绩查询学生成绩查询学生成绩查询case 7:save();break; //7. case 7:save();break; //7.学生成绩保存学生成绩保存学生成绩保存case 8: end();break; //8. case 8: end();break; //8.结束结束结束default:printf(" default:printf(" 请按相应数学选择系统功能:请按相应数学选择系统功能:请按相应数学选择系统功能:"); ");}}}void input() //1学生成绩输入成绩模块成绩输入成绩模块{int i,j,b;float a=0;printf(" printf(" 请输入该班同学的人数:请输入该班同学的人数:请输入该班同学的人数:\n"); \n");printf(" printf(" 班同学的人数在班同学的人数在1~%d 之间:之间:\n",MAXN); \n",MAXN);scanf("%d",&R);do{if(R<1||R>100){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&R);}b=R;} while(b<1||b>100);for(i=0;i<MAXM;i++){printf(" printf(" 请输入该班同学的第请输入该班同学的第请输入该班同学的第%d %d 门课程名称为:门课程名称为:\n",(i+1)); \n",(i+1));scanf("%s", &c[i].subject);}for(i=0;i<R;i++){printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的姓名:个同学的姓名:\n",(i+1)); \n",(i+1)); scanf("%s",&s[i].name);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的学号:个同学的学号:\n",(i+1)); \n",(i+1));scanf("%s",&s[i].num);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的性别(注:可以不详):\n",(i+1)); scanf("%s",&s[i].man);printf(" printf(" 请依次输入请依次输入请依次输入%d %d 门学科的成绩:门学科的成绩:\n",MAXM); \n",MAXM);for(j=0;j<MAXM;j++){printf(" printf(" 请输入课程请输入课程请输入课程%s %s 的成绩为:的成绩为:\n",c[j].subject); \n",c[j].subject);scanf("%f",&s[i].score[j]);a=a+s[i].score[j];}s[i].sum=a;s[i].avg=s[i].sum/MAXM;a=0;}}void sort() //2学生成绩插入成绩模块模块{int i,j,k,b;float a=0;printf(" printf(" 请输入要插入的学生的位置请输入要插入的学生的位置1~%d 号:号:\n",R); \n",R);printf(" printf(" 第几个学生的位置之后:第几个学生的位置之后:第几个学生的位置之后:\n"); \n");scanf("%d",&k);do{if(k<1||k>R){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&k);}b=k;}while(b<1||b>R);R=R+1;for(i=R;i>k;i--){strcpy(s[i].name,s[i-1].name);strcpy(s[i].num,s[i-1].num);strcpy(s[i].man,s[i-1].man);s[i].sum=s[i-1].sum;s[i].avg=s[i-1].avg;for(j=0;j<MAXM;j++) {s[i].score[j]=s[i-1].score[j];}}printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的姓名:个同学的姓名:\n",(k+1)); \n",(k+1));scanf("%s",&s[k].name);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的学号:个同学的学号:\n",(k+1)); \n",(k+1));scanf("%s",&s[k].num);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的性别(注:可以不详):\n",(k+1)); scanf("%s",&s[k].man);printf(" printf(" 请依次输入请依次输入请依次输入%d %d 门学科的成绩:门学科的成绩:\n",MAXM); \n",MAXM);for(j=0;j<MAXM;j++){printf(" printf(" 请输入课程请输入课程请输入课程%s %s 的成绩为:的成绩为:\n",&c[j].subject); \n",&c[j].subject);scanf("%f", &s[k].score[j]);a=a+s[k].score[j];}s[k].sum=a;s[k].avg=s[k].sum/MAXM;}void load() //3学生成绩修改学生成绩修改 {int load1(); int load2();int select,index,b;while(1){printf("*************************************************************\n");printf(" * 1.按学号修改按学号修改 * * \n");printf(" * 2.按姓名修改按姓名修改 * * \n"); printf(" * 0.返回返回 * * \n");printf(" * 请输入您的选择编号:请输入您的选择编号: * * \n");printf("*************************************************************\n");scanf("%d",&select);do{if(select<0||select>2){printf(" printf(" 您输入有误,请重新输入,谢谢!您输入有误,请重新输入,谢谢!!!\n"); scanf("%d",&select);}b=select;}while(b<0||b>2);switch(select){case 1:index=load1(); break;case 2:index=load2();break;case 0:return;}if(index!=-1){int i,j;float a=0,h[MAXM];i=index;printf(" printf(" 请输入请输入请输入%d %d 号的新学号:号的新学号: \n",i+1); \n",i+1);scanf("%s",&s[i].name);printf(" printf(" 请输入请输入请输入%d %d 号的新姓名:号的新姓名: \n",i+1); \n",i+1); scanf("%s",&s[i].num);printf(" printf(" 请输入第请输入第请输入第%d %d 个同学的性别(注:可以不详):\n",(i+1)); scanf("%s",&s[i].man);for(j=0;j<MAXM;j++){printf(" printf(" 请输入课程请输入课程请输入课程%s %s 的成绩为:的成绩为:\n",&c[j].subject); \n",&c[j].subject);scanf("%f",&h[j]);s[i].score[j] =h[j];a=a+s[i].score[j];}s[i].sum=a;s[i].avg=s[i].sum/MAXM;printf(" printf(" 修改成功。

学生成绩管理系统的设计与实现代码

学生成绩管理系统的设计与实现代码

学生成绩管理系统的设计与实现代码本系统有增加学生记录、修改学生记录、删除学生记录、按姓名查询学生记录、按C语言成绩对学生进行排序、退出系统6大功能。

能够对学生的姓名,学号,c语言成绩做相应的操作。

在检测到输入成绩大于55时,会自动加上5。

该管理系统设计功能模块图:下面是源代码:#include "stdio.h"#include "string.h"/*定义学生结构体*/struct Student{char ID[20]; //学号char Name[20]; //姓名float C_Mark; //C语言成绩};/*声明学生数组及学生数量*/struct Student students[1000];int num=0;/*通过学号返回数组下标*/int Student_SearchByIndex(char id[]) {int i;for (i=0;i<num;i++){if (strcmp(students[i].ID,id)==0) {return i;}}return -1;}/*通过姓名返回数组下标*/int Student_SearchByName(char name[]) {int i;for (i=0;i<num;i++){if (strcmp(students[i].Name,name)==0){return i;}}return -1;}/*显示单条学生记录*/void Student_DisplaySingle(int index){printf("%10s%10s%8s\n","学号","姓名","C语言成绩");printf("-------------------------------------------------------------\n");printf("%10s%10s%8.2f\n",students[index].ID,students[index] .Name,students[index].C_Mark);}/****1、增加学生记录*****/void Student_Insert(){while(1){printf("请输入学号:");scanf("%s",&students[num].ID);getchar();printf("请输入姓名:");scanf("%s",&students[num].Name);getchar();printf("请输入C语言成绩:");scanf("%f",&students[num].C_Mark);getchar();if (54<students[num].C_Mark && students[num].C_Mark< 60) //把55~59分之间的成绩都加上5分{students[num].C_Mark += 5;}num++;printf("是否继续?(Y/N),继续请按任意键,否则输入N:");if (getchar()=='N'){break;}}}/******2、修改学生信息**********/void Student_Modify(){while(1){char id[20];int index;printf("请输入要修改的学生的学号:");scanf("%s",&id);getchar();index=Student_SearchByIndex(id);if (index==-1){printf("该学生不存在!\n");}else{printf("你要修改的学生信息为:\n");Student_DisplaySingle(index);printf("-- 请输入新值--\n");printf("请输入学号:");scanf("%s",&students[index].ID);getchar();printf("请输入姓名:");scanf("%s",&students[index].Name);getchar();printf("请输入C语言成绩:");scanf("%f",&students[index].C_Mark);getchar();}printf("是否继续?(Y/N),继续请按任意键,否则输入N:");if (getchar()=='N'){break;}}}/****3、删除学生信息****/void Student_Delete(){int i;while(1){char id[20];int index;printf("请输入要删除的学生的学号:");scanf("%s",&id);getchar();index=Student_SearchByIndex(id);if (index==-1){printf("学生不存在!\n");}else{printf("你要删除的学生信息为:\n");Student_DisplaySingle(index);printf("是否真的要删除?(Y/N)");if (getchar()=='Y'){for (i=index;i<num-1;i++){students[i]=students[i+1];//把后边的对象都向前移动}num--;}getchar();printf("已删除\n");}printf("是否继续删除?(Y/N),继续请按任意键,否则输入N:");if (getchar()=='N'){break;}}}/****4、按姓名查询******/void Student_Select(){while(1){char name[20];int index;printf("请输入要查询的学生的姓名:");scanf("%s",&name);getchar();index=Student_SearchByName(name);if (index==-1){printf("学生不存在!\n");}else{printf("你要查询的学生信息为:\n");Student_DisplaySingle(index);}printf("是否继续?(Y/N),继续请按任意键,否则输入N:");if (getchar()=='N'){break;}}}/******5、按C语言成绩排序*******/void Student_SortByAverage(){int i,j;struct Student tmp;for (i=0;i<num;i++){for (j=1;j<num-i;j++){if (students[j-1].C_Mark<students[j].C_Mark){tmp=students[j-1];students[j-1]=students[j];students[j]=tmp;}}}}/*显示学生信息*/void Student_Display(){int i;printf("%10s%10s%8s\n","学号","姓名","成绩");printf("-------------------------------------------------------------\n");for (i=0;i<num;i++){printf("%10s%10s%8.2f\n",students[i].ID,students[i].Name ,students[i].C_Mark);}}/*将学生信息从文件(Database.txt)中读出*/void IO_ReadInfo(){FILE *fp;int i;if ((fp=fopen("Database.txt","rb"))==NULL){printf("不能打开文件!\n");return;}if (fread(&num,sizeof(int),1,fp)!=1){num=-1;}else{for(i=0;i<num;i++){fread(&students[i],sizeof(struct Student),1,fp);}}fclose(fp);}/*将学生信息写入文件(Database.txt)*/void IO_WriteInfo(){FILE *fp;int i;if ((fp=fopen("Database.txt","wb"))==NULL){printf("不能打开文件!\n");return;}if (fwrite(&num,sizeof(int),1,fp)!=1){printf("写入文件错误!\n");}for (i=0;i<num;i++){if (fwrite(&students[i],sizeof(struct Student),1,fp)!=1){printf("写入文件错误!\n");}}fclose(fp);}/***********主程序*********/void main(){int choice;IO_ReadInfo(); //读取文件while(1){/*主菜单*/printf("\n------ 学生成绩管理系统------\n");printf("1. 增加学生记录\n");printf("2. 修改学生记录\n");printf("3. 删除学生记录\n");printf("4. 按姓名查询学生记录\n");printf("5. 按C语言成绩排序\n");printf("6. 退出\n");printf("请选择(1-6):");scanf("%d",&choice);getchar();switch(choice){case 1:Student_Insert();break;case 2:Student_Modify();break;case 3:Student_Delete();break;case 4:Student_Select();break;case 5:Student_SortByAverage();Student_Display();break;case 6:exit(0);break;}IO_WriteInfo();}}1234567891011121415161718192021222324252627282930313233343637383940414243444546474849505152535455565859606162636465666768697071727374757677788081828384858687888990919293949596979899 100102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320322323324325326327328329330331332333334335336337338运行结果:测试第一个功能,输入四个学生的成绩:测试第二个功能,修改学生记录:测试第三个功能,删除学生记录:测试第四个功能,按姓名查询学生记录:测试第五个功能,显示所有学生的成绩,按照C语言成绩由高到底排序:我们可以看到,各项功能的实现,在第2个步骤中,将赵的成绩改为80,而第3个步骤删除了李的成绩。

C语言编写学生管理系统的代码

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语言版源代码

学生信息管理系统c语言版源代码

学生信息管理系统c语言版源代码#include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define N 1000typedef 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].gaoshu,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+student[i].jisuan ji;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,student[j].yingyu,student[i].jis uanji);}}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,student[j].yingyu,student[j].jis uanji);}}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,student[j].yingyu,student[i].jis uanji);}}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+student[i].jisuan ji;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);fhzjm();}void DaoChu(){struct student t;int i=0;FILE* fp = fopen("student.txt", "r");shuliang=0;if(NULL==fp){perror("读取文件打开失败~\n");return;}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语言源代码

学生管理系统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语言代码

学生管理系统 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语言版源代码)

学生成绩管理系统(数据结构C语言版源代码)-标准化文件发布号:(9556-EUATWK-MWUB-WUNN-INNUL-DDQTY-KII#include<stdio.h>#include<string.h>#include<stdlib.h>struct students{char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/struct students *next; /*用与构建连表指向下一结点*/};FILE *fp; /*定义全局变量fp*/void Revisemenu();/*修改菜单*/void Sortmenu();/*排序菜单*/void menu();/*主菜单*/void secret();/*安全验证*/struct students * Input();/*新建学生信息*/void fprint(struct students *head);/*将信息导入文件可追加*/void fprint_(struct students *head);/*将信息导入文件并覆盖*/void Browse(struct students *head);/*浏览全部学生信息*/struct students * create(struct students *head,int *n);/*从tushu_list中读取数据构建链表*/void FindofNum(struct students *head);/*按学号查询学生信息*/void FindofNname(struct students *head);/*按姓名查询学生信息*/void SortEnglish(struct students * head);/*按英语成绩排序*/void SortJava(struct students * head);/*按Java成绩排序*/void SortSjjg(struct students * head);/*按数据结构成绩排序*/void SortSzdl(struct students * head);/*按数字逻辑电路成绩排序*/void SortJsj(struct students * head);/*按计算机组成原理成绩排序*/struct students * Delete(struct students * head,char m[15]);/*按学号删除学生成绩信息*/struct students * Revise();/*修改学生信息(按编号修改)*//*主菜单*/void menu(){printf("\n\n");printf("***************************************************\n");printf(" 学生成绩管理系统 \n");printf("---------------------------------------------------\n");printf(" 1-添加新同学 2-浏览学生信息 \n");printf(" 3-按学号查询 4-按姓名查询 \n");printf(" 5-按成绩排序 6-修改学生信息 \n");printf(" 7-删除学生信息 0-退出系统 \n");printf("---------------------------------------------------\n");printf("___________________________________________________\n");}/*排序菜单*/void Sortmenu(){printf("\n\n");printf("***************************************************\n");printf(" 按成绩排序 \n");printf(" 1-大学英语 2-JAVA编程 \n");printf(" 3-数据结构 4-数字逻辑电路 \n");printf(" 5-计算机组成原理 0-返回上级菜单 \n");printf("***************************************************\n");}/*修改菜单*/void Revisemenu(){printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf(" 1--修改学生姓名 2--修改学生学号 \n");printf(" 3--修改学生性别 4--修改英语成绩 \n");printf(" 5--修改JAVA成绩 6--修改数据结构 \n");printf(" 7--修改数字电路 8--修改计算计 \n");printf(" 0--返回上级菜单 \n");printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");}/*安全验证*/void secret(){char a[20];printf("**欢迎来到学生信息管理系统,进入系统前请先进行密码验证---");printf(" ");do{gets(a); /*输入密码*/system("cls"); /*调用库函数清屏*/printf("对不起!您输入的密码有误,请重新输入---");}while(strcmp(a,"0605")!=0); /*单一密码"0605"*/system("cls");}/*新建学生信息*/struct students * Input(){struct students *p1,*p2,*head; /*建立辅助结点及头结点*/char Name;int n=0,x;printf("\n请按对应项输入学生信息以#结束:\n");printf("姓名学号性别英语 Java 数据结构数字电路计算机组成原理\n");p1=(struct students *)malloc(sizeof(struct students));head=p2=p1;do{ /*使用do while语句输入学生信息*/scanf("%s",&p1->Name);if(strcmp(p1->Name,"#")==0)break; /*判断结束符*/elsescanf("%s%s%lf%lf%lf%lf%lf",p1->Num,p1->Sex,&p1->English,&p1->Java,&p1->Sjjg,&p1->Szdl,&p1->Jsj);Name='#';p1=(struct students *)malloc(sizeof(struct students));p2->next=p1;p2=p1;n++;}while(1);p1->next=NULL;printf("学生信息输入结束!\n");getchar();printf("是否保存学生信息(1.是/2.否):");scanf("%d",&x);if(x==1)fprint(head); /*调用函数保存至文件*/elseprintf("\n文件没有被保存!\n");return head; /*返回头指针*/}/*将信息导入文件可追加*/void fprint(struct students *head){struct students *p1;if((fp=fopen("students_list.txt","a"))==NULL){printf("File open error!\n");exit(0);}for(p1=head;p1->next!=NULL;p1=p1->next) /*遍历*/fprintf(fp,"%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n", p1->Name,p1->Num,p1->Sex,p1->English,p1->Java,p1->Sjjg,p1->Szdl,p1->Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/printf("\n学生信息已成功保存到文件 students_list.txt 中!\n");getchar();}/*将信息导入文件并覆盖*/void fprint_(struct students *head){struct students *p1;if((fp=fopen("students_list.txt","w"))==NULL){printf("File open error!\n");exit(0);}for(p1=head;p1!=NULL;p1=p1->next) /*遍历*/fprintf(fp,"%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n", p1->Name,p1->Num,p1->Sex,p1->English,p1->Java,p1->Sjjg,p1->Szdl,p1->Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/;getchar();}/*浏览全部学生信息*/void Browse(struct students *head){char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/if((fp=fopen("students_list.txt","a+"))==NULL){printf("File open error!\n");exit(0);}printf("-------------------------------------------------------------\n");printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(!feof(fp))/*读取并输出*/{fscanf(fp,"%s%s%s%lf%lf%lf%lf%lf",Name,Num,Sex,&English,&Java,&Sjjg,&Sz dl,&Jsj);printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",Name,Num,Sex,English,Java,Sjjg,Szdl,Jsj);};if(fclose(fp)){printf("Can not close the file!\n");exit(0);}}/*从tushu_list中读取数据构建链表*/struct students * create(struct students * head,int *n){FILE *fp;struct students*p,*p1,*p2;if((fp=fopen("students_list.txt","a+"))==NULL){printf("File open error!\n");exit(0);}while(!feof(fp)){(*n)++;p=(struct students *)malloc(sizeof(struct students));fscanf(fp,"%s%s%s%lf%lf%lf%lf%lf",p->Name,p->Num,p->Sex,&p->English,&p->Java,&p->Sjjg,&p->Szdl,&p->Jsj);if(head==NULL){head=p;p1=p;}else{p1->next=p;p2=p1;p1=p;}}p2->next=NULL;free(p);(*n)--;fclose(fp);return head;}/*按姓名查询学生信息*/void FindofName(struct students *head){int i=0,n=0;char b[20];struct students *p;head=create(head,&n);p=head;printf("\n请输入要查询的学生姓名:");scanf("%s",b);while(p!=NULL){if(strcmp(p->Name,b)==0){printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);i++;}p=p->next;}if(i==0)printf("\n对不起!没有找到名为“%s”的学生信息!\n",b);}/*按学号查询学生信息*/void FindofNum(struct students *head){int i=0,n;char b[20];struct students *p;head=create(head,&n);p=head;printf("\n请输入要查询的学生学号:");scanf("%s",b);while(p!=NULL){if(strcmp(p->Num,b)==0){printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);i++;}p=p->next;}if(i==0)printf("\n对不起!没有找到学号为“%s”学生信息!\n",b);}/*按英语成绩排序*/void SortEnglish(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double English;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;English=p->English; /*将链表中第一个成绩赋给English*/while(p!=NULL){if((p->English)>English)/*比较*/English=p->English;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->English==English){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->English==English){ /*分数相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按英语成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按JAVA成绩排序*/void SortJava(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Java;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Java=p->Java; /*将链表中第一个成绩赋给Java*/while(p!=NULL){if((p->Java)>Java)/*比较*/Java=p->Java;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Java==Java){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Java==Java){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按Java成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按数据结构排序*/void SortSjjg(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Sjjg;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Sjjg=p->Sjjg; /*将链表中第一个成绩赋给Sjjg*/while(p!=NULL){if((p->Sjjg)>Sjjg)/*比较*/Sjjg=p->Sjjg;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Sjjg==Sjjg){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Sjjg==Sjjg){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按数据结构成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按数字电路排序*/void SortSzdl(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Szdl;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Szdl=p->Szdl; /*将链表中第一个成绩赋给Szdl*/while(p!=NULL){if((p->Szdl)>Szdl)/*比较*/Szdl=p->Szdl;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Szdl==Szdl){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Szdl==Szdl){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按数字电路成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按计算机组成原理排序*/void SortJsj(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Jsj;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Jsj=p->Jsj; /*将链表中第一个成绩赋给Jsj*/while(p!=NULL){if((p->Jsj)>Jsj)/*比较*/Jsj=p->Jsj;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Jsj==Jsj){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Jsj==Jsj){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按计算机组成原理成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按学号删除学生成绩信息*/struct students * Delete(struct students * head,char m[15]){struct students *ptr1,*ptr2;int n;printf("\n所有学生信息如下:\n");Browse(head);printf("\n请输入想要删除的学生学号:");scanf("%s",m);head=create(head,&n);if(head==NULL){printf("无学生信息!\n");return head;}if((strcmp(head->Num,m)==0)&&head!=NULL){ptr2=head;head=head->next;free(ptr2);}if(strcmp(head->Num,m)!=0){ptr1=head;ptr2=head->next;while(ptr2!=NULL){if(strcmp(ptr2->Num,m)==0){ptr1->next=ptr2->next;free(ptr2);}elseptr1=ptr2;ptr2=ptr1->next;}}fprint_(head);printf("\n学号为' %s '学生信息已被删除,并保存至文件!\n",m);return head;}/*修改学生信息(按编号修改)*/struct students * Revise(){int n=0,t;char num[10];char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/struct students *head=NULL;struct students *p;printf("\n所有学生信息如下:\n");Browse(head);head=create(head,&n);printf("\n输入需要修改的学生的学号:");scanf("%s",num);p=head;while(head!=NULL){if(strcmp(p->Num,num)==0){system("cls");Revisemenu();printf("编号为%s的学生信息如下:\n",num);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);while(1){printf("请选择需要修改的信息:");scanf("%d",&t);switch(t){case 1:printf("请输入新姓名:");scanf("%s",Name);strcpy(p->Name,Name);break;case 2:printf("请输入新学号:");scanf("%s",&Num);strcpy(p->Num,Num);break;case 3:printf("请输入新性别:");scanf("%s",Sex);strcpy(p->Sex,Sex);break;case 4:printf("请输入新英语成绩:");scanf("%lf",&English);p->English=English;break;case 5:printf("请输入新Java成绩:");scanf("%lf",&Java);p->Java=Java;break;case 6:printf("请输入新数据结构成绩:");scanf("%lf",&Sjjg);p->Sjjg=Sjjg;break;case 7:printf("请输入新数字电路成绩:");scanf("%lf",&Szdl);p->Szdl=Szdl;break;case 8:printf("请输入新计算机组成原理成绩:");scanf("%lf",&Jsj);p->Jsj=Jsj;break;case 0:system("cls");menu();goto lab;break;default:printf("对不起,输入有误!");break;}}}elsep=p->next;}lab:fprint_(head);printf("修改完成,并储存至文件!\n");return head;}/*主函数*/void main(){int choice,ch;char m[15];struct students *head=NULL;secret();menu();while(1){printf("请输入选项:");scanf("%d",&choice);switch(choice){case 1:Input();break;case 2:system("cls");menu();Browse(head);break;case 3:system("cls");menu();FindofNum(head);break;case 4:system("cls");menu();FindofName(head);break;case 5:system("cls");Sortmenu();do{printf("请输入您的选择:");scanf("%d",&ch);switch(ch){case 1:system("cls");Sortmenu();SortEnglish(head);break;case 2:system("cls");Sortmenu();SortJava(head);break;case 3:system("cls");Sortmenu();SortSjjg(head);break;case 4:system("cls");Sortmenu();SortSzdl(head);break;case 5:system("cls");Sortmenu();SortJsj(head);break;}}while(ch!=0);system("cls");menu();break;case 6:system("cls");menu();Revise();break;case 7:system("cls");menu();head=Delete(head,m);break;case 0:system("cls");printf("\t\t欢迎下次再来!");exit(0);default:printf("对不起,输入有误!");break;}}return ;}。

学生录入成绩C语言代码,学生成绩管理系统C语言源代码.doc

学生录入成绩C语言代码,学生成绩管理系统C语言源代码.doc

学⽣录⼊成绩C语⾔代码,学⽣成绩管理系统C语⾔源代码.doc 学⽣成绩管理系统C语⾔源代码#include"stdio.h"#include#include#include"process.h"#include"ctype.h"typedef struct{char num[10];char name[10];int c;int math;int English;double aver;}Student;Student stu[99];int shuru(Student stud[],int n)/*输⼊若⼲条记录*/{int i=0;char sign,x[10];double a=0.0;while(sign!='n'&&sign!='N'){printf("输⼊学⽣学号:");scanf("%s",stu[n+i].num);printf("输⼊学⽣姓名:");scanf("%s",stu[n+i].name);printf("输⼊学⽣的C、数学、英语");scanf("%d%d%d",&stu[n+i].c,&stu[n+i].math,&stu[n+i].English);a=1.0*(stu[n+i].c+stu[n+i].math+stu[n+i].English/3);stu[n+i].aver=a;gets(x); /*清除多余的输⼊*/printf("是否继续输⼊?(Y/N):\n");scanf("%c",&sign);i++;}return(n+i);}void xianshi(Student stud[],int n) /*显⽰所有记录*/{int i ;printf("----------------------------------------------------------\n"); /*格式头*/printf("学号 姓名 C 数学 英语 平均成绩 \n");printf("----------------------------------------------------------\n");for(i=0;i{printf("%-10s%-10s%-10d%-10d%-10d%-10.2lf\n",stu[i].num,stu[i].name,stu[i].c,stu[i].math,stu[i].English,stu[i].aver); }}void xiugai(Student stud[],int n) /*修改*/{int i=0,choice=1;char x[10];while(choice!=0){printf("请输⼊您要修改的学⽣的学号:\n");scanf("%s",x);for(i=0;;i++){if(strcmp(stu[i].num,x)==0)break;}printf("请选择您要修改的内容:\n");printf(" ---------------------- \n");printf("| 姓名 请按 1 |\n");printf("| c 请按 2 |\n");printf("| 数学分数 请按 3 |\n");printf("| 英语分数 请按 4 |\n"); printf("| 退出 请按 0|\n"); printf("+-----。

C语言学生管理系统代码

C语言学生管理系统代码
float average; //平均分
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语言学生信息管理系统(完整版)

C语言学生信息管理系统(完整版)

#define PRINT0 printf("name:%s\nsex:%s\nage:%d\nID_card:%d\naddress:%s\n",st[i].name,st[i].sex,st[i].age,st[i] .ID_card,st[i].addr)#define PRINT1 printf("prefession:%s\nstudent_number:%d\n*****score*****\nwuli:%d\n",st[i].prefession,st[i] .student_number,st[i].score.wuli)#define PRINT2 printf("gaoshu:%d\nyingyu:%d\ntiyu:%d\naverage: %d\n",st[i].score.gaoshu,st[i].score.yingyu,st[i ].score.tiyu,st[i].score.aver)#define print1 printf("________________________________")#define N 2#include "string.h"#include "stdio.h"int sum=0;struct score{int wuli;int gaoshu;int yingyu;int tiyu;int aver;};struct message{ char name[10];int age;char sex[5];int ID_card;char addr[30];char prefession[30];int student_number;struct score score;}st[100];/*************write message*************/write_message(){ int flag;char chioce;do{system("cls");flag=2; sum++;printf("_______________________________");printf("please input student's message:\n");printf("\n");print1;printf("%dth student message:",sum);print1;printf("\nname:");scanf("%s",st[sum].name);printf("\nsex:");scanf("%s",st[sum].sex);printf("\nage:");scanf("%d",&st[sum].age);printf("\nID_card:");scanf("%d",&st[sum].ID_card);printf("\naddress:");scanf("%s",st[sum].addr);printf("\nprefession:");scanf("%s",st[sum].prefession);printf("\nschool number:");scanf("%d",&st[sum].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[sum].score.wuli);printf("\ngaoshu:");scanf("%d",&st[sum].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[sum].score.yingyu);printf("\ntiyu:");scanf("%d",&st[sum].score.tiyu);printf("\naverage:");scanf("%d",&st[sum].score.aver);do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*************save message****************/save_message(){ FILE *fp;int i;if((fp=fopen("student.txt","wb"))==NULL){printf("read error \n");printf("press any key back to menu\n");getch();exit(1);}for(i=0;i<sum;i++)if(fwrite(&st[i],sizeof(struct message),1,fp)!=1){printf("write error\n");fclose(fp);}fclose(fp);printf("\n********___OK!___**********\n___press any key back___");sum=i;bioskey(0);}/***************add message*****************/add_message(){int i,j,flag; char chioce;i=0;j=sum-1;flag=0;do{ system("cls");i++; j++;print1;printf("add %dth student's meaasge\n",i);print1;printf("\nname:");scanf("%s",st[j].name);printf("\nsex:");scanf("%s",st[j].sex);printf("\nage:");scanf("%d",&st[j].age);printf("\nID_card:");scanf("%d",&st[j].ID_card);printf("\naddress:");scanf("%s",st[j].addr);printf("\nprefession:");scanf("%s",st[j].prefession);printf("\nstudent_number:");scanf("%d",&st[j].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[j].score.wuli);printf("\ngaoshu:");scanf("%d",&st[j].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[j].score.yingyu);printf("\ntiyu:");scanf("%d",&st[j].score.tiyu);printf("\naverage:");scanf("%d",&st[j].score.aver);printf("\n\nweather add %dth student's message: \n",i+1);do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;}while(1);}while(flag==1);sum=j+1;save_message();}/**********inqiure message******/inqiure_message(){int chioce;do{system("cls");printf("**********choose 0-3**********\n\n\n");printf(" 1:name inquire\n\n\n");printf(" 2:IDcard inqiure\n\n\n");printf(" 3:student_number\n \n\n");printf(" 0:back menu\n\n\n");scanf("%d",&chioce);switch(chioce){case 1: name_inqiure();break;case 2: ID_card_inqiure();break;case 3: grade_inqiure();break;case 0:break;}}while(chioce!=0);}/**********name inqiure*********/name_inqiure(){char NAME[30];int i; int flag,k;char chioce;do{ system("cls");k=0;printf("please input the message you inqiure");printf("\nname:");scanf("%s",NAME);getchar();printf("\n");for(i=0;i<sum;i++){if(strcmp(st[i].name,NAME)==0){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/**********IDcard inqiure*********/ID_card_inqiure(){int card;int i; int flag,k;char chioce;do{ clrscr(); k=0;printf("please input the message you inqiure");printf("\nIDcard:");scanf("%d",&card);getchar();printf("\n");for(i=0;i<sum;i++){if(st[i].ID_card==card){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/*********grade inqiure***********/grade_inqiure(){int GRADE;int i; int flag,k;char chioce;do{ system("cls");k=0;printf("please input the message you inqiure");printf("\nstudent_number:");scanf("%d",&GRADE);getchar();printf("\n");for(i=0;i<sum;i++){if(st[i].student_number==GRADE){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/*********change message**********/change_message(){char pre[30],chioce;int i,gra,flag,num,s;s=0;do{system("cls");printf("please input message you want to change\n ");printf("student_number:");scanf("%d",&gra); getchar();for(i=0;i<sum;i++){if(st[i].student_number==gra){PRINT0;PRINT1;PRINT2;printf("\n********input message you want to change********\n");printf("0:name***1:sex***2:age***3:ID_card***4:address***\n5:prefession***6:wuli***7:stud ent_number***8\n:gaoshu***9:yingyu***10:tiyu***11:average***________\n");printf("choose 0-11\n");scanf("%d",&num); getchar();switch(num){case 0: printf("input the name changed\n");scanf("%s",st[i].name); getchar(); break;case 1: printf("input the sex changed\n");scanf("%s",st[i].sex); getchar(); break;case 2: printf("input the age changed\n");scanf("%d",&st[i].age); getchar(); break;case 3: printf("input the ID_card changed\n");scanf("%d",&st[i].ID_card); getchar(); break;case 4: printf("input the address changed\n");scanf("%s",st[i].addr); getchar(); break;case 5: printf("input the prefession changed\n");scanf("%s",st[i].prefession); getchar(); break;case 6: printf("input the wuli_score changed\n");scanf("%d",&st[i].score.wuli); getchar(); break;case7: printf("input the student_number changed\n");scanf("%d",&st[i].student_number); getchar(); break;case 8: printf("input the gaoshu_score changed\n");scanf("%d",&st[i].score.gaoshu); getchar(); break;case 9: printf("input the yingyu_score changed\n");scanf("%d",&st[i].score.yingyu); getchar(); break;case 10: printf("input the tiyu_score changed\n");scanf("%d",&st[i].score.tiyu); getchar(); break;case 11: printf("input the average_score changed\n");scanf("%d",&st[i].score.aver); getchar(); break;default: printf("input error\n"); break;}printf("\n*********the changed message*********\n\n");PRINT0;PRINT1;PRINT2;s=1;}}if(s!=1) printf("without message you want to change\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*********delete message**********/delete_message(){ int GRADE;int i,j,flag1,flag;char chioce1,chioce2;flag1=3;flag=3;do{ system("cls");printf("please input student's student_number you want to delete\n");printf("student_number:");scanf("%d",&GRADE); getchar();for(i=0;i<sum;i++)if(st[i].student_number==GRADE){do{PRINT0;PRINT1;PRINT2;printf("\n******************************\n_________________ _________________\n");printf("press y/Y deleted:\npress n/N cancel:\n");scanf("%c",&chioce1);getchar();system("cls");if(chioce1=='y'||chioce1=='Y') flag1=1;else if(chioce1=='n'||chioce1=='N') return;else {printf("***input error***\n___press any ker return___\n"); bioskey(0);}}while(flag1!=1);for(j=i;j<sum;j++){ st[j]=st[j+1];flag=2;printf("message was deleted\n");sum-=1; }}if(flag!=2) printf("without message you want to delete\n");do{printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce2);printf("****************************\n");if(chioce2=='y'||chioce2=='Y') {flag=1; break;}else if(chioce2=='n'||chioce2=='N') {flag=0; break;}else {system("cls");printf("input error\n");}print1;printf("\n");}while(1);}while(flag==1);save_message();}/************insert message*************/insert_message(){ int chioce,flag,i; flag=2;do{system("cls");printf("please input the number of people you insert\n");scanf("%d",&chioce);if(chioce>=sum){printf("xin xi pai zai zui hou ");chioce=sum;}for(i=sum;i>chioce;i--) st[i]=st[i-1];printf("\nplease input message you insert");printf("\nname:");scanf("%s",st[i].name);printf("\nsex:");scanf("%s",st[i].sex);printf("\nage:");scanf("%d",&st[i].age);printf("\nID_card:");scanf("%d",&st[i].ID_card);printf("\naddress:");scanf("%s",st[i].addr);printf("\nprefession:");scanf("%s",st[i].prefession);printf("\ngrade:");scanf("%d",&st[i].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[i].score.wuli);printf("\ngaoshu:");scanf("%d",&st[i].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[i].score.yingyu);printf("\ntiyu:");scanf("%d",&st[i].score.tiyu);printf("\naverage:");scanf("%d",&st[i].score.aver);sum+=1;do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*********school_number_order***********/grade_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].student_number>st[j].student_number){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("grade order from min to max\n");for(i=0;i<sum;i++){ print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);bioskey(0);}/***********wuli score order***************/wuli_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.wuli>st[j].score.wuli){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("wuli score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********gaoshu score order***************/gaoshu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.gaoshu>st[j].score.gaoshu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("gaoshu score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********yingyu score order***************/yingyu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.yingyu>st[j].score.yingyu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("yingyu score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********tiyu score order***************/tiyu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.tiyu>st[j].score.tiyu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("yitu order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********average score order***************/average_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.wuli>st[j].score.wuli){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("average score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/********order message****************/order_message(){int chioce;do{system("cls");printf("**********choose 0-6**********\n\n");printf(" 1:grade order\n\n");printf(" 2:wuli score order\n\n");printf(" 3:gaoshu score order\n \n");printf(" 4:ying yu score order\n\n");printf(" 5:tiyu score order\n\n");printf(" 6:average score order\n\n");printf(" 0:back menu\n\n");scanf("%d",&chioce);switch(chioce){case 1: grade_order();break;case 2: wuli_order();break;case 3: gaoshu_order();break;case 4: yingyu_order();break;case 5: tiyu_order();break;case 6: average_order();break;case 0:break;}}while(chioce!=0);}/**********answer secretory***********/mima_message(){int flag;char answer[10];char secret[10]="abcd";flag=2;do{system("cls");printf("\n______________________mi ma wei 'abcd'________________\n\n");printf("______________________qing shu ru mi ma:");scanf("%s",answer);getchar();if(strcmp(secret,answer)==0){flag=1;printf("\n\n =====throngh=====\n\n\n");printf("____________________press any key into next:\n");bioskey(0);}else{flag=0;printf("______________________input error:\n");printf("______________________press any key to return:\n");bioskey(0);}}while(flag!=1);}/*********read message****************/read_message(){int i;system("cls");if(sum<=0){ printf("without message\n");getch();return;}for(i=0;i<sum;i++){system("cls");print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;printf("\n********press any key -show the next one********\n ");getch();}printf("________________totle num :%d________________\n",sum); printf("_____________press any key return______________\n"); bioskey(0);}/*************************************/main(){int chioce,flag;mima_message();do{system("cls");chioce=9;printf("**********************************************\n");printf("****welcome to system of managing students****\n");printf("**********************************************\n\n");printf("-------------------choose 0-8-----------------\n\n");printf(" 1:write message\n\n");printf(" 2:add message\n\n");printf(" 3:inqiure name\n\n");printf(" 4:change message\n\n");printf(" 5:insert message\n\n");printf(" 6:order message\n\n");printf(" 7:delete message\n\n");printf(" 8:read messaeg\n\n");printf(" 0:***exit***\n\n");scanf("%d",&chioce);getchar();switch(chioce){case 1: write_message();break;case 2: add_message();break;case 3: inqiure_message();break;case 4: change_message();break;case 5: insert_message();break;case 6: order_message();break;case 7: delete_message();break;case 8: read_message();break;case 0: printf("___sure press y/Y:___\n\n___no sure press n/N:___");scanf("%c",&chioce);getchar();if(chioce=='y'||chioce=='Y') flag=0;else flag=1;break;default : printf("\n ___input error___\n\n");printf("***press any key to go on***\n");getch();break;}}while(flag!=0);save_message();system("cls");printf("\n\n___message was saved___\n\n\n*****file name is student.txt*****\n");bioskey(0);}。

C++学生成绩管理系统源代码

C++学生成绩管理系统源代码

C++学生成绩管理系统源代码————————————————————————————————作者:————————————————————————————————日期:#include<iostream.h>#include<fstream.h>#include<stdlib.h>#include<string.h>#include<stdio.h>class Person{ public:char name[8];};class student:public Person //构建学生类{public:friend void Manage(student stud[]) ;friend void Input(student stud[]) ;friend void Statistic(student stud[]);friend void Lookup(student stud[]) ;friend void Modify(student stud[]) ;friend void Output(student stud[]) ;friend void Insert(student stud[]) ;friend void Write(student stud[],int n);friend int Read(student stud[]);private:int num;char name[8];char class_0[20];float c_program;float english;float math;float average;int order;}stud[100];class Manage:public student{};void Write(student stud[],int n) //向文件中写入数据{fstream myFile;myFile.open("score.txt",ios::out|ios::binary);if(!myFile){cout<<"score.txt can't open!"<<endl;abort();}int count=n;myFile<<count<<endl<<endl;for(int i=0;i<=count;i++){myFile<<stud[i].class_0<<" "<<stud[i].num<<" "<<stud[i].name<<" "<<stud[i].c_program<<" "<<stud[i].english<<" "<<stud[i].math<<" "<<stud[i].average<<endl;}myFile.close();}int Read(student stud[]) //从文件中读数据{fstream myFile;myFile.open("score.txt",ios::in|ios::binary);if(!myFile){cout<<"score.txt can't open!"<<endl;abort();}int count;myFile.seekg(0);myFile>>count;for(int i=0;i<=count;i++){myFile>>stud[i].class_0>>stud[i].num>>stud[i].name>>stud[i].c_program>>stud[i].english>>stu d[i].math >>stud[i].average;}myFile.close();return count ;}void Input(student stud[]) //---------------输入学生成绩{system("cls"); /*运行前清屏*/int i=0;int flag;char sign;cout<<endl<<">>>>>>>> 请输入学生成绩<<<<<<<<\n"<<endl;while(sign!='n'&&sign!='N') /*判断*/{cout<<"班级:"; /*交互输入*/cin>>stud[i].class_0;loop:cout<<"学号:";cin>>stud[i].num;int c=0;while(c<i){c++;if(stud[i].num==stud[i-c].num){cout<<"你输入的学号已经存在!请重新输入!"<<endl;goto loop;}}cout<<"姓名:";cin>>stud[i].name;do{flag=0;cout<<"C++成绩:";cin>>stud[i].c_program;if(stud[i].c_program>100 ||stud[i].c_program<1)cout<<"请输入1-100之间的数字!\n";elseflag=1;}while(flag==0);do{flag=0;cout<<"英语成绩:";cin>>stud[i].english;if(stud[i].english>100 ||stud[i].english<1)cout<<"请输入1-100之间的数字!\n";elseflag=1;}while(flag==0);do{flag=0;cout<<"数学成绩:";cin>>stud[i].math;if(stud[i].math>100 ||stud[i].math<1)cout<<"请输入1-100之间的数字!\n";elseflag=1;}while(flag==0);stud[i].average=(stud[i].c_program+stud[i].english+stud[i].math)/3;cout<<"平均分:"<<stud[i].average<<endl;cout<<"继续录入学生成绩?(y/n)";cin>>sign; /*输入判断*/i++;}Write(stud,i);}void Statistic(student stud[]) //---------------统计学生数据{system("cls"); /*运行前清屏*/int n=Read(stud);cout<<endl<<">>>>>>>> 显示学生成绩<<<<<<<<\n"<<endl;cout<<"班级"<<"\t "<<"学号"<<"\t "<<" 姓名"<<"\t "<<" 平均分"<<endl; for(int i=0;i<n;i++)cout<<stud[i].class_0<<"\t"<<stud[i].num<<"\t"<<stud[i].name<<"\t"<<stud[i].average<<endl;system("pause");}void Lookup(student stud[]) //---------------查找学生成绩{int p;cout<<"请选择1.按学号查找 2.按姓名查找"<<endl;cin>>p;if(p==1){system("cls"); /*运行前清屏*/int n=Read(stud);int s;int i=0;cout<<endl<<">>>>>>>> 查找学生成绩<<<<<<<<\n"<<endl;cout<<"请输入查找学生的学号:"<<endl;cin>>s;while((stud[i].num-s)!=0&&i<n) i++; /*查找判断*/if(i==n){cout<<"没有该学生的信息!"<<endl; /*输入失败信息*/}else{cout<<"---------------------------"<<endl;cout<<"班级:"<<stud[i].class_0<<endl; /*输出该学生信息*/cout<<"学号:"<<stud[i].num<<endl;cout<<"姓名:"<<stud[i].name<<endl;cout<<"C++:"<<stud[i].c_program<<endl;cout<<"英语:"<<stud[i].english<<endl;cout<<"数学:"<<stud[i].math<<endl;cout<<"平均分:"<<stud[i].average<<endl;}}if(p==2){system("cls"); /*运行前清屏*/int m=Read(stud);char t;int i=0;cout<<endl<<">>>>>>>> 查找学生成绩<<<<<<<<\n"<<endl;cout<<"请输入查找学生的姓名:"<<endl;cin>>t;while(strcmp(stud[i].name-t,stud[i].name)==0&&i<m) i++; /*查找判断*/{cout<<"---------------------------"<<endl;cout<<"班级:"<<stud[i].class_0<<endl; /*输出该学生信息*/cout<<"学号:"<<stud[i].num<<endl;cout<<"姓名:"<<stud[i].name<<endl;cout<<"C++:"<<stud[i].c_program<<endl;cout<<"英语:"<<stud[i].english<<endl;cout<<"数学:"<<stud[i].math<<endl;cout<<"平均分:"<<stud[i].average<<endl;}}}void Modify(student stud[]) //---------------修改学生成绩{system("cls"); /*运行前清屏*/int n=Read(stud);int s,a; float q;int i=0;cout<<endl<<">>>>>>>> 修改学生成绩<<<<<<<<\n"<<endl;cout<<"输入修改成绩学生的学号:"<<endl;cin>>s;while((stud[i].num-s)!=0&&i<n) i++; /*查找判断*/if(i==n){cout<<"没有该学生的成绩!"<<endl; /*输入失败信息*/}else{cout<<"----------该学生的信息----------\n"<<endl; /*格式头*/cout<<"班级"<<"\t"<<"学号"<<"\t"<<"姓名"<<"\t"<<"c++"<<"\t"<<"英语"<<"\t"<<"数学"<<"\t"<<"平均分"<<endl;cout<<"---------------------------------"<<endl;cout<<stud[i].class_0<<"\t"<<stud[i].num<<"\t"<<stud[i].name<<"\t"<<stud[i].c_program<<"\t"<<stud[i].english<<"\t"<<stud[i].math<<"\t"<<stud[i].average<<endl;cout<<"---------------------------------"<<endl;cout<<"请输入要修改的课程号"<<endl;cout<<"1.c语言2.英语3.数学"<<endl;cin>>a;cout<<"重新输入分数"<<endl;cin>>q;if(a==1) stud[i].c_program=q;if(a==2)stud[i].english=q;if(a==3)stud[i].math=q;stud[i].average=(stud[i].c_program+stud[i].english+stud[i].math)/3;cout<<"----------该学生的信息----------\n"<<endl; /*格式头*/cout<<"班级"<<"\t"<<"学号"<<"\t"<<"姓名"<<"\t"<<"c++"<<"\t"<<"英语"<<"\t"<<"数学"<<"\t"<<"平均分"<<endl;cout<<"---------------------------------"<<endl;cout<<stud[i].class_0<<"\t"<<stud[i].num<<"\t"<<stud[i].name<<"\t"<<stud[i].c_program<< "\t"<<stud[i].english<<"\t"<<stud[i].math<<"\t"<<stud[i].average<<endl;char c;cout<<"是否保存数据?(y/n)"<<endl;cin>>c;if(c!='n'&&c!='N')Write(stud,n);}}void Insert(student stud[]) //---------------增加学生成绩{system("cls"); /*运行前清屏*/int n=Read(stud);char s;cout<<endl<<"************ 插入学生成绩***********\n"<<endl;while(s!='n'&&s!='N'){cout<<"班级:"<<endl; /*交互输入*/cin>>stud[n].class_0;cout<<"学号:";cin>>stud[n].num;cout<<"姓名:";cin>>stud[n].name;cout<<"C++成绩:";cin>>stud[n].c_program;cout<<"英语成绩:";cin>>stud[n].english;cout<<"数学成绩:";cin>>stud[n].math;stud[n].average=(stud[n].c_program+stud[n].english+ stud[n].math)/3;cout<<"平均分"<<stud[n].average;n++;cout<<"插入成功!"<<endl; /*返回成功信息*/cout<<"是否继续输入(y/n)"<<endl;cin>>s;}Write(stud,n);}void Manage(student stud[]) //---------------按平均分对学生成绩记录项进行降序排序{system("cls"); /*运行前清屏*/int i,j,k;float s;char t[20];cout<<endl<<"********** 排列管理成绩**********\n"<<endl;int n=Read(stud);for(i=0;i<n-1;i++) /*冒泡法排序*/for(j=0;j<n-1-i;j++)if(stud[j].average<stud[j+1].average){strcpy(t,stud[j+1].class_0);strcpy(stud[j+1].class_0,stud[j].class_0);strcpy(stud[j].class_0,t);k=stud[j+1].num;stud[j+1].num=stud[j].num;stud[j].num=k;strcpy(t,stud[j+1].name);strcpy(stud[j+1].name,stud[j].name);strcpy(stud[j].name,t);s=stud[j+1].c_program;stud[j+1].c_program=stud[j].c_program;stud[j].c_program=s;s=stud[j+1].english;stud[j+1].english=stud[j].english;stud[j].english=s;s=stud[j+1].math;stud[j+1].math=stud[j].math;s=stud[j+1].average;stud[j+1].average=stud[j].average;stud[j].average=s;}cout<<"-------------------------------------"<<endl; /*格式头*/cout<<"班级"<<"\t "<<"学号"<<"\t "<<"姓名"<<"\t"<<"C++"<<"\t"<<"英语"<<"\t"<<"数学"<<"\t"<<"平均分"<<"\t"<<"名次"<<endl;for(i=0;i<n;i++) /*循环输入*/{stud[i].order=i+1;cout<<stud[i].class_0<<"\t"<<stud[i].num<<"\t"<<stud[i].name<<"\t"<<stud[i].c_program<< "\t"<<stud[i].english<<"\t"<<stud[i].math<<"\t"<<stud[i].average<<"\t "<<stud[i].order<<endl;}Write(stud,n);}void Output(student stud[]) //---------------显示全部学生成绩{system("cls"); /*运行前清屏*/int n=Read(stud);cout<<"***************** 显示班级学生成绩*****************\n"<<endl;if(!stud)cout<<"没有记录";else{cout<<"-------------------------------------------------------------------------"<<endl; /*格式头*/ cout<<"班级"<<"\t "<<"学号"<<"\t "<<"姓名"<<"\t"<<"c++"<<"\t"<<"英语"<<"\t"<<"数学"<<"\t"<<"平均分"<<endl;for(int i=0;i<n;i++) /*循环输入*/{cout<<stud[i].class_0<<"\t"<<stud[i].num<<"\t"<<stud[i].name<<"\t"<<stud[i].c_program<<"\t "<<stud[i].english<<"\t " <<stud[i].math<<"\t"<<stud[i].average<<endl;}cout<<"-------------------------------------------------------------------------"<<endl;}}int menu() /*菜单函数*/{char c;do{system("cls"); /*运行前清屏*/cout<<"*******************************************************\n"<<endl;cout<<" -----------------欢迎使用学生成绩管理系统-------------\n"<<endl;cout<<" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;cout<<" * 【1】输入学生成绩*"<<endl;cout<<" * 【2】显示学生成绩* "<<endl;cout<<" * 【3】查找学生成绩* "<<endl;cout<<" * 【4】修改学生成绩* "<<endl;cout<<" * 【5】插入学生成绩* "<<endl;cout<<" * 【6】排列管理成绩* "<<endl;cout<<" * 【7】显示班级学生成绩* "<<endl;cout<<" * 【0】退出本系统* " <<endl;cout<<" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ "<<endl;cout<<"请你选择(0-7):"<<endl;c=getchar(); /*读入选择*/}while(c<'0'||c>'8');return(c-'0'); /*返回选择*/}void main() /*主函数*/{for(;;){switch(menu()) /*选择判断*/{case 1:Input(stud);/*输入学生成绩*/break;case 2:Statistic(stud); /*输出学生统计数据*/break;case 3:Lookup(stud); /*查找学生成绩*/cout<<"\t\t\t";system("pause");break;case 4:Modify(stud); /*修改学生成绩*/cout<<"\t\t\t";system("pause");break;case 5:Insert(stud);/*增加学生成绩*/cout<<"\t\t\t";system("pause");break;case 6:Manage(stud); /*按平均分对成绩记录项进行降序排序*/cout<<"\t\t\t";system("pause");break;case 7:Output(stud); /*显示全部学生成绩*/cout<<"\t\t\t";system("pause");break;case 0:cout<<endl<<" ===========================感谢您使用学生成绩管理系统==========================\n"<<endl; /*结束程序*/cout<<"\t\t\t";system("pause");exit(0);}}}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

C程序学生管理系统/*Note:Your choice is C IDE*/#include"stdio.h"#include"stdlib.h"#include"string.h"typedef struct student//定义学生{char name[10];int number;char sex[2];int math;int eglish;int clanguge;int average;}student;typedef struct unit//定义接点{student date;struct unit*next;}unit;unit*build()//建立链表并返回指针{unit*p;if((p=(unit*)malloc(sizeof(unit)))==NULL){printf("=>初始化失败!");return0;}else{p->next=NULL;p->date.number=0;//头结点存放学生人数printf("初始化成功!\n");return p;}}void add(unit*head)//增加学生{unit*p,*q;int m,n=0;q=head->next;p=(unit*)malloc(sizeof(unit));printf("=>请输入新生姓名!\n");gets(p->);fflush(stdin);printf("=>请输入学号!\n");while(n==0){scanf("%d",&m);fflush(stdin);if(q==NULL)n=1;while(q){if(q->date.number==m){printf("=>你输入的学号与已有同学的学号相同,请重新输入!\n");q=head->next;break;}else{q=q->next;if(q==NULL)n=1;}}}p->date.number=m;printf("=>请输入性别!\n");gets(p->date.sex);fflush(stdin);printf("=>请输入数学成绩\n");scanf("%d",&m);fflush(stdin);p->date.math=m;printf("=>请输入英语成绩\n");scanf("%d",&m);fflush(stdin);p->date.eglish=m;printf("=>请输入c语言成绩\n");scanf("%d",&m);fflush(stdin);p->date.clanguge=m;p->date.average=(p->date.math+p->date.eglish+p->date.clanguge);q=head->next;head->next=p;p->next=q;head->date.number++;}void deletion(unit*head)//删除一名学生{unit*p=head->next,*q=head;char N[10];printf("=>请输入你想删除的学生姓名!\n");gets(N);fflush(stdin);if(p==NULL)printf("=>系统无学生可删除!\n");while(p){if(strcmp(p->,N)==0){q->next=p->next;head->date.number--;printf("=>删除%s成功!\n",p->);free(p);break;}else{p=p->next;q=q->next;if(p==NULL)printf("=>你要删除的学生不存在,删除失败!\n");}}}int display(unit*head)//显示学生信息{unit*p=head->next;int m,n=0;char N[10];if(p==NULL){printf("=>系统无学生!\n");return0;}while(n==0){printf("********************************************************* *********************\n");printf("=>请选择你的操作!\n");printf("=>\t\t\t1.显示所有\t2.按姓名查找\n\t\t\t3.按学号查找\t4.返回主菜单\n");scanf("%d",&m);fflush(stdin);switch(m){case1:printf("\n=>该系统拥有%d名学生!\n\n",head->date.number);p=head->next;printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t综合\n\n");while(p){printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->,p->date.numb er,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);p=p->next;}break;case2:printf("=>请输入查找姓名!\n");gets(N);fflush(stdin);p=head->next;while(p){if(strcmp(p->,N)==0){printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t 综合\n");printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->,p->date.numb er,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);break;}else{p=p->next;if(p==NULL)printf("=>你要查的学生不存在!");}}break;case3:printf("=>请输入查找学号!\n");scanf("%d",&m);fflush(stdin);p=head->next;while(p){if(p->date.number==m){printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t 综合\n");printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->,p->date.numb er,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);break;}else{p=p->next;if(p==NULL)printf("=>你要查的学生不存在!\n");}}break;case4:n=1;break;}}return1;}int range(unit*head)//排序{unit*p=head,*q=head->next;int n,i,m=head->date.number;printf("********************************************************* **********************\n");printf("\t\t\t1.按学号\t2.按成绩\n\n");printf("=>请选择操作!\n》");scanf("%d",&n);fflush(stdin);if(q==NULL){printf("=>无学生可排序!\n");return0;}switch(n){case2:for(i=0;i<m;i++)//按总分排序{p=head;q=head->next;while(q->next){if((q->date.average)<(q->next->date.average)){p->next=q->next;p=p->next;q->next=p->next;p->next=q;}else{p=p->next;q=q->next;}}}break;case1:for(i=0;i<=m;i++)//按学号排序{p=head;q=head->next;while(q->next){if((q->date.number)>(q->next->date.number)){p->next=q->next;p=p->next;q->next=p->next;p->next=q;}else{p=p->next;q=q->next;}}}break;}printf("=>排序成功!\n");return1;}void menu(){printf("\n*********************************主菜单***************************************\n");printf("\t\t\t1.新建系统\t2.添加学生\n\t\t\t3.删除学生\t4.查看信息\n\t\t\t5.排列顺序\t6.读取信息\n\t\t\t7.保存信息\t8.退出系统\n");printf("=>请选择你的操作!\n");}int save(unit*head)//保存{FILE*fp;unit*p;p=head;if((fp=fopen("d:\\学生","wb+"))==NULL){printf("=>保存失败!");return0;}while(p){fwrite(&(p->date),sizeof(student),1,fp);p=p->next;}printf("=>保存成功!");fclose(fp);return1;}unit*read()//读入系统学生信息{int i;unit*p,*q,*head;FILE*fp;if((head=(unit*)malloc(sizeof(unit)))==NULL) {printf("=>开辟空间失败!");exit(1);}else{head->next=NULL;head->date.number=0;//头结点存放学生人数}q=head;if((fp=fopen("d:\\学生","rb"))==NULL){printf("=>系统无学生!\n");return0;}fread(&(q->date),sizeof(student),1,fp);for(i=0;i<head->date.number;i++){if((p=(unit*)malloc(sizeof(unit)))==NULL){printf("=>读值失败!");exit(1);}fread(&(p->date),sizeof(student),1,fp);p->next=q->next;q->next=p;}fclose(fp);return head;}void main(){int m=0,n,i;unit*head;printf("************************************************************* *******************\n\n");printf("\t\t\t*欢迎使用学生成绩管理系统*\n");printf("\n\t\t\t\t\t\t\t\t编译员:岳英明\n\n");printf("=>正在读取系统信息......\n");if((head=read())==0){printf("=>是否新建?\n");printf("\t\t\t是(1)\t\t否(2)\n");scanf("%d",&i);fflush(stdin);if(i==1)head=build();else if(i==2)exit(1);}elseprintf("=>信息导入成功!");while(m==0){menu();scanf("%d",&n);fflush(stdin);switch(n){case1:head=build();break;case2:add(head);break;case3:deletion(head);break;case4:display(head);break;case5:range(head);break;case6:head=read();if(head!=0)printf("=>读取存盘成功!\n");break;case7:save(head);break;case8:m=1;break;}}}。

相关文档
最新文档