学生成绩管理系统c语言代码
c语言学生成绩查询
#include<stdio.h>struct student(int num;char name[20];char sex[10];int age;float computer;float math;float English;float sum_score;};int max(struct student a[]Jnt n)(int kJ;float m;m=a[0].sum_score;k=0;for(i=l;i<3;i++){if(m<a[i].sum_score){k=i;m=a[i].sum_score;)}return k;)void paixiul(struct student a[]Jnt n)(int i,j;for(i=0;i<n-l;i++){for(j=i+l;j<n-l;j++){if(a[i].sum_score>a[j].sum-score){a[n]=a[i];a[i]=aUl;aU]=a[n];)void paixiu2(struct student a[],int n)(int i,j;for(i=0;i<n-l;i++){for(j=i+l;j<n-l;j++){if(a[i].computer>a[j].computer) {a[n]=a[i];a[i]=aUl;aU]=a[n];))})void paixiu3(struct student a[],int n)(int i,j;for(i=0;i<n-l;i++){for(j=i+l;j<n-l;j++){if(a[i].math>a[j].math){a[n]=a[i];a[i]=aUl;aU]=a[n];))})void paixiu4(struct student a[],int n)(int i,j;for(i=0;i<n-l;i++){for(j=i+l;j<n-l;j++){if(a[i].English>a[j].English){a[n]=a[i];a[i]=aUl;a[j]=a[n];)〃学生成绩管理系统的设计与实现〃学生信息:〃学号num〃姓名name〃性别sex〃年龄age〃计算机成绩computer〃数学成绩math〃英语成绩English〃总成绩sum_score〃要求:void main()(int i/n/mJ/t=3/a[100]={100}/k=l;float max_sum;struct student stu[100]={{1001;,zhangsan";'g",21,98,75,SeiJlOOZ/'lisi'V'b",20,78,63/92}/{1003;'wangwu"/"g",2 1,90,88,70}};printf("请选择:1:输出2:求学生总分3:求总分最高分学生的基本信息4:按总分排序5:按计算机成绩排序6战数学成绩排序7:按英语成绩排序8:按学号查找某位同学9:从键盘输入某位学生信息,插入到数组中10:从键盘输入学号,删除该学号的学生信息0:退出:\n");scanf(“%d”,&m);for(i=0;i<t;i++)stu[i].sum_score=stu[i].computer+stu[i].math+stu[i].English;while(m!=0){switch(m){case 1:{for(j=0;j<t;j++)(if(j!=a[k-l])printf("%d %s %s%d %f %f %f %f\n",stu[j].num,stu[j].name z stu[j].sex,stu[j].age z stu[j].compu ter,stu[j].math z stu[j].English/stu[j].sum_score);)}break;case 2:for(j=0;j<t;j++)if(j!=a[k-l])printf(H%s %f\n,,/stu[j].name/stuO].sum_score);)}break;case 3:{n=max(stu,t);printf("%d %s %s %d %f %f %f %f\n"/stu[n].num/stu[n].name/stu[n].sex/stu[n].age/stu[n].co mputeostu[n].math/stu[n].English/stu[n].sum_score);}break;case 4:{paixiul(stu z t+l);for(j=0;j<t;j++)(if(j!=a[k-l])printf("%d %s %s%d %f %f %f %f\n",stu[j].num/stu[j].name/stu[j].sex/stu[j].age/stu[j].compu ter/stu[j].math/stu[j].English/stu[j].sum_score);)}break;case 5:{paixiu2(stu z t+l);for(j=0;j<t;j++)(if(j!=a[k-l])printf("%d %s %s%d %f %f %f %f\n",stu[j].num/stu[j].name/stu[j].sex/stu[j].age/stu[j].compu ter/stu[j].math/stu[j].English/stu[j].sum_score);)}break;case 6:{paixiu3(stu z t+l);for(j=0;j<t;j++)(printf("%d %s %s %d %f %f %f %f\n,,/stuO].num/stu[j].name/stuO].sex/stuO].age/stu[j].computer/stu[j].math/stu[j].English/stu[j].sum_score);)}break;case 7:{paixiu4(stu,t+l);for(j=0;j<t;j++)(if(j!=a[k-l])printf("%d %s %s%d %f %f %f %f\n"/stu[j].num/stu[j].name/stu[j].sex z stu[j].age/stu[j].computer/stu[j].math/stu[j].English/stu[j].sum_score);)}break;case 8:{printf(“请输入学号\n“);scanf("%d”,&n);for(i=0;i<t;i++)(if(n==stu[i].num) break;)if(i!=t)printf("%d %s %s %d %f %f %f %f\n',/stu[ij.num/stu[i].name/stu[i].sex/stu[i].age/stu[i].compu ter/stu[i].math z stu[i].English/stu[i].sum_score);elseprintf("查无此人\n");}break;case 9:{t++;printf("请输入学生信息\n”);scanf(H%d %s %s %d %f %f %f,,,&stu[t-l].num/stu[t-l].name/stu[t-l].sex,&stu[t-l].age/&stu[t -l].computer,&stu[t-l].math,&stu[t-l].English);stu[t-l].sum_score=stu[t-l].computer+stu[t-l].math+stu[t-l].English;for(j=0;j<t;j++)(if(stu[t-l].num!=stu[j].num)(for(j=0;j<t;j++)if(j!=a[k-l])printf("%d %s %s%d %f %f %f %f\n"/stu[j].num/stu[j].name/stu[j].sex/stu|j].age/stu[j].compu ter,stu[j].math,stu[j].English,stu[j].sum_score);})elseprintf("学号重合,有误\n");break;)}break;case 10:{printf ("请输入学号\n”);scanf("%d",&n);for(i=0;i<t;i++)(if(n==stu[i].num)break;)a[k]=i;if(a[k]!=t)(for(j=0;j<t;j++)(if(j!=a[k])printf("%d %s %s%d %f %f %f %f\n"/stu[j].num/stu[j].name/stu[j].sex,stu|j].age/stu[j].compu ter,stu[j].math,stu[j].English,stu[j].sum_score);))else(printf("查无此人\n");for(j=0;j<t;j++)printf("%d %s %s%d %f %f %f %f\n"/stu[j].num/stu[j].name/stu[j].sex,stu|j].age/stu[j].compu ter,stu[j].math,stu[j].English,stu[j].sum_score);)k++;}break;}printf("请选择:1:输出2:求学生总分3:求总分最高分学生的基本信息全按总分排序5:按计算机成绩排序6:按数学成绩排序7:按英语成绩排序8:按学号查找某位同学9:从键盘输入某位学生信息,插入到数组中10:从键盘输入学号,删除该学号的学生信息0:退出:\n");scanf("%d",&m);})〃⑴定义结构体数组,并初始化学生信息(总成绩不需要输入)〃(2)输出学生基本信息〃⑶求每位同学的总分〃⑷求总分最高分学生的基本信息〃⑸按总分排序〃⑹按某一个科成绩排序〃⑺按学号查找某位同学〃⑻从键盘输入某位学生信息,插入到数组中〃⑼从键盘输入学号,删除该学号的学生信息〃要求使用菜单完成。
学生管理系统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语言源程序
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语言简单版
学生管理系统c语言简单版学生管理系统c语言简单版介绍:学生管理系统是一种用于管理学生信息的软件,它可以方便地对学生的基本信息、课程成绩等进行录入、查询、修改和删除等操作。
本文将介绍如何使用C语言编写一个简单的学生管理系统。
功能:1. 添加学生信息2. 查询学生信息3. 修改学生信息4. 删除学生信息5. 显示所有学生信息实现方法:1. 添加学生信息添加学生信息需要输入以下内容:姓名、性别、年龄、班级和电话号码。
我们可以定义一个结构体来存储这些信息,代码如下:```struct Student {char name[20];char sex[10];int age;char class[20];char phone[20];};```然后定义一个数组来存储多个学生的信息:```struct Student students[100];int count = 0; // 学生数量```接下来,我们可以编写一个函数来添加新的学生信息:```void addStudent() {struct Student student;printf("请输入姓名:");scanf("%s", );printf("请输入性别:");scanf("%s", student.sex);printf("请输入年龄:");scanf("%d", &student.age);printf("请输入班级:");scanf("%s", student.class);printf("请输入电话号码:");scanf("%s", student.phone);students[count++] = student; // 将新的学生信息存储到数组中 printf("添加成功!\n");}```2. 查询学生信息查询学生信息可以按照姓名或电话号码进行查询。
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语言编写的学生成绩管理系统的简单代码,可以用vc运行(供参考)#include"stdio.h"#include”stdlib。
h"#include"string。
h”typedefstruct student//定义学生{char name[10];int number;char sex[2];int math;int eglish;int clanguge;int average;}student;typedefstruct unit//定义接点{studentdate;struct unit*next;}unit;unit大build()//建立链表并返回指针{unit*p;if((p=(unit*)malloc(sizeof(unit)))==NULL){printf("二>初始化失败!”);return0;}else{p—>next=NULL;p-〉date.number=O;//头结点存放学生人数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。
学生绩点计算系统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语言课程设计—学生成绩管理系统
#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语言--学生信息管理系统代码
#include <stdio.h>#include <stdlib.h>#include <string.h>#define FUNC_NEW 1 /* 建立新的班级学生数据*/#define FUNC_SA VE 2 /*把数据写入文件并保存*/#define FUNC_OPEN 3 /*打开文件并从里读入数据*/#define FUNC_INSERT 4 /*插入一个学生的信息*/#define FUNC_SEARCH 5 /*查找学生的信息*/#define FUNC_CHANGE 6 /*修改学生的信息*/#define FUNC_DELETE 7 /*删除学生的信息*/#define FUNC_DISPLAY 8 /*展示学生的信息*/#define FUNC_CENSUS 9 /*分段统计学生总分人数并打印*/ #define FUNG_EXIT 10/*结束程序*/#define FUNC_CLOSE 10#define MAX_NUM 45#define MAX_NAME_STRLEN 30void DoSave();void DoOpen();void DoNew();void DoInsert();void DoDisplay();void DoDelete();void DoSearch();void DoChange();void Docensus();void DoExit();//用户定义的类型声明struct _student{int id;char name[MAX_NAME_STRLEN];int Math;int English;int Chinese;int Physics;int Chemistry;float averScore;int sum;};typedef struct _student STUD;struct _studTb{STUD stud[MAX_NUM];int length;};//全局变量的定义struct _studTb si;char strClassId[15];int main(){int iUserSelect;int MainMenu();system("color 20");for(;;){iUserSelect = MainMenu();if(FUNC_CLOSE == iUserSelect)break;switch(iUserSelect){case FUNC_NEW:DoNew();break;case FUNC_OPEN:DoSave();break;case FUNC_SA VE:DoOpen();break;case FUNC_INSERT:DoInsert();break;case FUNC_SEARCH:DoSearch();break;case FUNC_CHANGE:DoChange();break;case FUNC_DELETE:DoDelete();break;case FUNC_DISPLAY:DoDisplay();break;case FUNC_CENSUS:Docensus();break;case FUNC_CLOSE :DoExit();break;default:break;}}}int MainMenu(){int iUserSelect;system("cls");printf(" --------------------------------------------------------------------- \n");printf(" | ***********欢迎来到学生管理系统********** |\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");printf(" | ****** 10> 退出学生系统****** | \n");printf(" | *****Please select a function id(1..9) to execute:***** | \n");printf(" --------------------------------------------------------------------- \n");scanf("%d",&iUserSelect);if(iUserSelect<1&&iUserSelect>9)printf("请正确输入指令\n");elsereturn iUserSelect;}void DoNew(){int number,i;system("cls");printf("\t\tFUNCION: 新建一个班级:\n");printf("\t\t请输入班级序号(string):");scanf("%s",strClassId);printf("\t\t请输入这个班有多少人:");scanf("%d",&number);for (i = 0; i < number; i++){printf("\t\t请输入学生学号:");scanf("%d",&si.stud[i].id);printf("\t\t请输入学生姓名:");scanf("%s",si.stud[i].name);printf("\t\t请输入学生成绩:\n");printf("\t\tMath English Chinese Physics Chemistry\n");scanf("%4d %4d %4d %4d %4d",\& si.stud[i].Math,& si.stud[i].English,& si.stud[i].Chinese,& si.stud[i].Physics,& si.stud[i].Chemistry);}si.length = number;}//保存学生信息void DoSave(){FILE *fp;int i;system("cls");if((fp=fopen("stu-list.txt","wb"))==NULL){printf("打开文件失败\n");return;}for(i=0;i<si.length;i++){if(fwrite(&si.stud[i],sizeof(si),1,fp)==1)printf("保存成功\n");}fclose(fp);}//开文件读取学生信息void DoOpen(){FILE *fp;int i=0;system("cls");if((fp=fopen("stu-list.txt","ab+"))==NULL){printf("打开文件失败\n");return;}while(!feof(fp)){if(fread(&si.stud[i],sizeof(si),1,fp)==1)i++;}fclose(fp);for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 数学:%d 英语:%d 语文:%d 物理:%d 化学:%d\n",si.stud[i].id,si.stud[i].name,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}//插入学生信息void DoInsert(){FILE *fp;int j,INid,sid;int m=0,i=0,k=0;system("cls");if((fp=fopen("stu-list.txt","ab+"))==NULL){ printf("\t文件打开失败!");getchar();return;}while(!feof(fp)){if(fread(&si.stud[i],sizeof(si),1,fp)==1)m++;i++;}/*if(m==0){printf("没有学生记录!");fclose(fp);return;}*/printf("\t请输入要插入信息在那个学号之后:\n");scanf("%d",&INid);for(i=0;i<m;i++)if(INid==si.stud[i].id)break;for(j=m-1;j>i;j--)si.stud[j+1]=si.stud[j];stare1:printf("\t请输入要插入的学生的信息:\n");printf("\t请输入要插入的学号");scanf("%d",&sid);while(k<m){if(si.stud[k].id==sid){printf("\t 该学号已经存在,不允许重复插入!\n");goto stare1;}k++;}si.stud[i+1].id=sid;printf("\t请输入你想输入的姓名");scanf("%s",si.stud[i+1].name);printf(" Math English Chinese Physics Chemistry\n");scanf("%d %d %d %d %d",& si.stud[i+1].Math,& si.stud[i+1].English,& si.stud[i+1].Chinese,& si.stud[i+1].Physics,& si.stud[i+1].Chemistry);si.length=si.length+1;DoSave();}//在文件中查找学生信息,支持姓名学号查找void DoSearch(){int i=0,choice,Sid;char sname[MAX_NAME_STRLEN];int flag=0;system("cls");DoOpen();printf("\n1按姓名查找:\n2按学号查找:");scanf("%d",&choice);switch(choice){case 1: printf("请你输入要查找的姓名");scanf("%s",sname);while(i<si.length){if(strcmp(si.stud[i].name,sname)==0){flag=1;printf("学号:%d 姓名:%s 数学成绩:%d 英语成绩:%d 语文成绩:%d 物理成绩:%d 化学成绩:%d\n",si.stud[i].id,si.stud[i].name ,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}i++;}if(flag==0)printf("你输入的姓名不存在,请确认后再输入");break;case 2: printf("请你输入要查找的学号");scanf("%d",&Sid);while(i<si.length){if(Sid==si.stud[i].id){flag=1;printf("学号:%d 姓名:%s 数学成绩:%d 英语成绩:%d 语文成绩:%d 物理成绩:%d 化学成绩:%d\n",si.stud[i].id,si.stud[i].name ,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}i++;}if(flag==0)printf("你输入的学号不存在,请确认后再输入");break;}printf(" Please input a number to continue!");scanf("%d",&i);return;}//对学生信息进行修改void DoChange(){int choice1;int i=0;int onum;char choice2;system("cls");DoOpen();printf("你想对那个学生进行操作,请输入学号\n");scanf("%d",&onum);while(onum!=si.stud[i].id)i++;if(onum==si.stud[i].id){printf("\n你要修改哪一项");printf("1学号\n2姓名\n3数学成绩\n4英语成绩\n5语文成绩\n6物理成绩\n7化学成绩");printf("请选择");scanf("%d",&choice1);switch(choice1){case 1: printf("\n请输入修改后的学号");scanf("%d",&si.stud[i].id);break;case 2: printf("\n输入你要修改的姓名");scanf("%s",&si.stud[i].name);break;case 3: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Math);break;case 4: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].English);break;case 5: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Chinese);break;case 6: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Physics);break;case 7: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Chemistry);break; }}elseprintf("没有该同学信息");printf(" Please input a number(0..9) to continue!");scanf("%d",&i);}//删除学生信息void DoDelete(){int i,id;char fname[MAX_NAME_STRLEN];system("cls");DoOpen();printf("请输入学生学号");scanf("%d",&id);i=0;while(si.stud[i].id!=id)i++;if(si.stud[i].id==id){while(i<si.length-1){si.stud[i]=si.stud[i+1];i++;}si.length=si.length-1;for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 数学:%d 英语:%d 语文:%d 物理:%d 化学:%d \n",si.stud[i].id,si.stud[i].name,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}elseprintf("没有该同学信息");printf(" Please input a number(0..9) to continue!");scanf("%d",&i);}//展示学生信息void DoDisplay(){struct _studTb m;int i,j,n;system("cls");DoOpen();printf("请选择\n1.数学排名2.英语排名3.语文排名 4.物理排名 5.化学排名 6.学生总分并排序7.学生平均分并排序\n");scanf("%d",&n);if(n==1){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j-1;i++)if(si.stud[i].Math<si.stud[i+1].Math){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 数学成绩排名:%d\n", si.stud[i].id, si.stud[i].name ,si.stud[i].Math);}else if(n==2){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].English<si.stud[i+1].English){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 英语成绩排名:%d\n", si.stud[i].id, si.stud[i].name ,si.stud[i].English);}else if(n==3){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].Chinese<si.stud[i+1].Chinese){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 语文成绩排名:%d\n", si.stud[i].id, si.stud[i].name, si.stud[i].Chinese);}else if(n==4){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].Physics<si.stud[i+1].Physics){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s OS成绩排名:%d\n", si.stud[i].id, si.stud[i].name, si.stud[i].Physics);}else if(n==5){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].Chemistry<si.stud[i+1].Chemistry){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s C语言成绩排名:%d\n", si.stud[i].id, si.stud[i].name,si.stud[i].Chemistry);}else if(n==6){for(i=0;i<si.length;i++)si.stud[i].sum=si.stud[i].Math+si.stud[i].English+si.stud[i].Chinese+si.stud[i].Physics+si.stud [i].Chemistry;for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].sum<si.stud[i+1].sum){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 总分成绩排名:%f\n", si.stud[i].id, si.stud[i].name, si.stud[i].sum);}else if(n==7){for(i=0;i<si.length;i++){si.stud[i].sum=si.stud[i].Math+si.stud[i].English+si.stud[i].Chinese+si.stud[i].Physics+si.stud [i].Chemistry;si.stud[i].averScore=(float)si.stud[i].sum/si.length;}for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].averScore<si.stud[i+1].averScore){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 平均成绩排名:%f\n", si.stud[i].id, si.stud[i].name, si.stud[i].averScore);}printf(" Please input a number(0..9) to continue!");scanf("%d",&i);}//统计学生信息void Docensus(){struct _studTb sen;int mark;int sum=0;int i=0;system("cls");DoOpen();printf("请输入要统计多少分以上的学生信息");scanf("%d",&mark);while(i<si.length){ if(si.stud[i].Math>mark){sen.stud[sum]=si.stud[i];sum++;}i++;}printf("一共有:%d人\n",sum);for(i=0;i<sum;i++)printf("他的学号%4d姓名%s数学成绩%4d英语成绩%4d 语文成绩%4d 物理成绩%4d 化学成绩%4d\n ",sen.stud[i].id,sen.stud[i].name,sen.stud[i].Math,sen.stud[i].English,sen.stud[i].Chinese,sen.stud[i].Physics,sen.stud[i].Chemistry);printf(" Please input a number(0..9) to continue:");scanf("%d",&i);}void DoExit(){printf("\t\t 谢谢使用!\n");printf("\t\t");system("pause");exit(0);}。
统计成绩的C语言代码
#include <stdio.h>#include <math.h>#include <string.h>struct student{int chin,math,engl,chem,phys,sum;float ave;char name[5];}stu[5];void main(){void a();void b();void c();void d();void e();void f();int n;while(n!=7){printf(" 正方成绩管理系统\n");printf("1:输入各个学生的成绩\n");printf("2:显示各位同学的总分\n");printf("3:输出各个同学的平均成绩\n");printf("4:输出对总分的排名\n");printf("5:输出对平均分的排名\n");printf("6:输出对各科的排名\n");printf("7:退出系统\n");printf("输入功能代码:");scanf("%d",&n);switch(n){case 1:a();break;case 2:b();break;case 3:c();break;case 4:d();break;case 5:e();break;case 6:f();break;case 7:printf("\n********谢谢使用正方成绩管理系统******\n");break;break;}}getchar();}void a(){int i;for(i=0;i<5;i++){printf("请输入姓名语文成绩数学成绩英语成绩化学成绩物理成绩\n");scanf("%s%d%d%d%d%d",&stu[i].name,&stu[i].chin,&stu[i].math,&stu[i].engl,&stu[i].chem, &stu[i].phys);}for(i=0;i<5;i++){stu[i].sum=stu[i].chin+stu[i].math+stu[i].engl+stu[i].chem+stu[i].phys;stu[i].ave=(stu[i].sum)/5.0;}}void b(){int i;printf("姓名语文成绩数学成绩英语成绩化学成绩物理成绩总分\n");for(i=0;i<5;i++)printf("%3s %7d %7d %7d %7d %7d %7d\n",stu[i].name,stu[i].chin,stu[i].math, stu[i].engl,stu[i].chem,stu[i].phys,stu[i].sum);}void c(){int i;printf("姓名语文成绩数学成绩英语成绩化学成绩物理成绩平均分\n");for(i=0;i<5;i++)printf("%3s %7d %7d %7d %7d %7d %4.2f\n",stu[i].name,stu[i].chin,stu[i].mat h,stu[i].engl,stu[i].chem,stu[i].phys,stu[i].ave);}void d(){int a[5]={0,1,2,3,4};int i,j,temp;for(j=0;j<4;j++){for(i=0;i<4-j;i++)if(stu[a[i]].sum<stu[a[i+1]].sum){temp=a[i];a[i]=a[i+1];a[i+1]=temp;}}printf("顺序为:\n");printf("姓名总分\n");for(i=0;i<5;i++)printf("%3s %7d\n",stu[a[i]].name,stu[a[i]].sum);printf("\n");}void e(){int a[5]={0,1,2,3,4};int i,j,temp;for(j=0;j<4;j++){for(i=0;i<4-j;i++)if(stu[a[i]].ave<stu[a[i+1]].ave){temp=a[i];a[i]=a[i+1];a[i+1]=temp;}}printf("顺序为:\n");printf("姓名平均分\n");for(i=0;i<5;i++)printf("%3s %7f\n",stu[a[i]].name,stu[a[i]].ave);printf("\n");}void f(){int a[5]={0,1,2,3,4};int i,j,temp;for(j=0;j<4;j++){for(i=0;i<4-j;i++)if(stu[a[i]].chin<stu[a[i+1]].chin){temp=a[i];a[i]=a[i+1];a[i+1]=temp;}}printf("排序为:\n");printf("姓名语文\n");for(i=0;i<5;i++)printf("%3s %7d\n",stu[a[i]].name,stu[a[i]].chin); printf("\n");for(j=0;j<4;j++){for(i=0;i<4-j;i++)if(stu[a[i]].math<stu[a[i+1]].math){temp=a[i];a[i]=a[i+1];a[i+1]=temp;}}printf("排序为:\n");printf("姓名数学\n");for(i=0;i<5;i++)printf("%3s %7d\n",stu[a[i]].name,stu[a[i]].math); printf("\n");for(j=0;j<4;j++){for(i=0;i<4-j;i++)if(stu[a[i]].engl<stu[a[i+1]].engl){temp=a[i];a[i]=a[i+1];a[i+1]=temp;}}printf("排序为:\n");printf("姓名英语\n");for(i=0;i<5;i++)printf("%3s %7d\n",stu[a[i]].name,stu[a[i]].engl); printf("\n");for(j=0;j<4;j++){for(i=0;i<4-j;i++)if(stu[a[i]].chem<stu[a[i+1]].chem){temp=a[i];a[i]=a[i+1];a[i+1]=temp;}}printf("排序为:\n");printf("姓名化学\n");for(i=0;i<5;i++)printf("%3s %7d\n",stu[a[i]].name,stu[a[i]].chem);printf("\n");for(j=0;j<4;j++){for(i=0;i<4-j;i++)if(stu[a[i]].phys<stu[a[i+1]].phys){temp=a[i];a[i]=a[i+1];a[i+1]=temp;}}printf("排序为:\n");printf("姓名物理\n");for(i=0;i<5;i++)printf("%3s %7d\n",stu[a[i]].name,stu[a[i]].phys);printf("\n");}。
学生管理系统c语言源代码
学生管理系统c语言源代码学生管理系统c语言源代码#include stdio.h#include dos.h#include string.h#include stdlib.h#include malloc.h#define SIZE 8struct student{char name;char num;int score;float ave;struct student *next;}stu[SIZE],temp,s;void shuru(){int i,j,sum,length,flag=1,a;FILE *fp;while(flag==1){printf(“Define a rangeclass number:");scanf("%d",printf("Input the total number of the class(a):"); scanf("%d",length);if(lengtha)flag=0;}for(i=0;ilength;i++){printf("\n请输入学生的信息:");printf("\n输入姓名:");scanf("%s",stu[i].name);printf("\n输入序号.:");scanf("%s",stu[i].num);printf("\n输入成绩:\n");sum=0;for(j=0;jj++){printf("score %d:",j+1);scanf("%d",stu[i].score[j]);sum+=stu[i].score[j];}stu[i].ave=sum/3.0;}学生管理系统c语言源代码fp=fopen("stu1.txt","w");for(i=0;ilength;i++)if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)printf("File write error\n");fclose(fp);fp=fopen("stu1.txt","r");printf("\name\ NO. score1 score2 score3 sum ave\n");for(i=0;ilength;i++){fread(stu[i],sizeof(struct student),1,fp);printf("%3s%5s%7d%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i ].score,stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score,stu[i].ave);}}void chaxun(){ FILE *fp, *fp1;char n,name;int i,j,k,t,m,flag=1;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");k=i;printf("\nPlease select the menu(1.number ):"); scanf("%d",switch(m){case 1:printf("\nchaxun number:");scanf("%s",n);for(flag=1,i=0;ii++){if(strcmp(n,stu[i].num)==0){j=i;flag=0;break;}}break;case 2:printf("\nchaxun name:");scanf("%s",name);for(flag=1,i=0;ii++){if(strcmp(name,stu[i].name)==0){j=i;flag=0;break;学生管理系统c语言源代码}}}if(!flag){printf("\nYou can find:\n");fp1=fopen("stu2.txt","w");printf(" name NO. score1 score2 score3ave\n");fwrite(stu[j],sizeof(struct student),1,fp1);printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j].score,stu[j].score,stu[j].ave);}else printf("\nNot found!");fclose(fp);fclose(fp1);}xiugai(){ int a;printf("\nplease select the menu(1.CHARU 2.__ ):");scanf("%d",switch(a){case 1:Insert(); break;case 2:Delete(); break;}}Insert(){ FILE *fp;int i,j,t,n;printf("\nNO.:");scanf("%s",s.num);printf("name:");scanf("%s",);printf("score1,score2,score3:");scanf("%d,%d,%d",s.score,s.score,s.score);s.ave=(s.score+s.score+s.score)/3.0;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)学生管理系统c语言源代码printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(t=0;stu[t].aves.avett++);printf("\nnow:\n");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fwrite(s,sizeof(struct student),1,fp);printf("\n%-15s%11s%7d%7d%7d%10.2f",,s.num,s.score,s.score, s.score,s.ave);for(i=t;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);}Delete(){ FILE *fp;int i,j,t,n,flag;char number;if((fp=fopen("stu1.txt","rb"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;学生管理系统c语言源代码printf("\nInput number deleted:");scanf("%s",number);for(flag=1,i=0;flagii++){if(strcmp(number,stu[i].num)==0){for(t=i;tt++){strcpy(stu[t].num,stu[t+1].num);strcpy(stu[t].name,stu[t+1].name);for(j=0;jj++)stu[t].score[j]=stu[t+1].score[j];stu[t].ave=stu[t+1].ave;}n=n-1;elseprintf("\n Not found!");printf("\nNow,the content of file:\n");fp=fopen("stu1.txt","wb");for(i=0;ii++)fwrite(stu[i],sizeof(struct student),1,fp);fclose(fp);fp=fopen("stu1.txt","r");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)printf("%-15s%11s%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i].score, stu[i].score,stu[i].score,stu[i].ave);fclose(fp);}paixu(){FILE *fp;int i,j,n;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(i=0;ii++)for(j=i+1;jj++)学生管理系统c语言源代码if(stu[i].avestu[j].ave){temp=stu[i];stu[i]=stu[j];stu[j]=temp;}printf("\nnow:");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);tongji(){ FILE *fp;int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0; int a10=0; float t;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++){printf("\n%-15s%11s",stu[i].name,stu[i].num); for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);k=i;for(i=0;ii++){labe1=0;if(stu[i].ave60){labe1++;t=labe1/(float)k*100;}}printf("\nbujigelv:");printf("%f%",t);printf("\n");for(j=0;jj++){a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;k=i;printf("kemu is %d:\n",j);for(i=0;ii++)学生管理系统c语言源代码{b=stu[i].score[j]/10;if(b6)a5++;elseif(b=6b7)a6++;elseif(b=7b8)a7++;elseif(b=8b9)a8++;if(b=9b10)a9++;elseif(b==10)a10++;}printf(" 不及格is %d\n",a5);printf(" 60--69 is %d\n",a6);printf(" 70--79 is %d\n",a7);printf(" 80--89 is %d\n",a8);printf(" 90--99 is %d\n",a9);printf(" 100 is %d\n",a10);}}main(){int a;printf(" ____\n"); printf(" 欢迎进入学生成绩管理系统\n");printf(" ____\n"); while(1){printf("\n选择菜单:\n");printf("\n");printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出\n"); scanf("%d",switch(a){case 1: shuru();break;case 2: chaxun(); break;case 3: paixu(); break;case 4: xiugai(); break;学生管理系统c语言源代码case 5: tongji();break; case 6: exit(0); }。
学生管理系统 C语言代码
#include"stdio.h"#include"stdlib.h"#include"string.h"struct stu_info1{char num[13];//学号char name[10];//姓名char sex[5];//性别char cls[20];//班级}stu1[6];struct stu_info2{char counum[6];//课程号char counam[20];//课程名称int credit;//学分}stu2[6];struct stu_info3{char num[13];//学号char counum[6];//课程号float results;//分数}stu3[12];struct stu_info4{char num[13];//学号char counum[6];//课程号float results;//分数}stu4[12];int n=11;void main(){void gengxin();void input1();void input2();void input3();void output();void xianshi();void chaxun();void printf1();void printf2();input1();input2();output();int i;loop: ;printf("*************欢迎使用分数查询系统*************\n");printf("** 请选择**\n");printf("** 1.录入2.删除无用信息(管理员功能) **\n");printf("** 3.显示4.查询(学生功能) **\n");printf("** 5.显示学生信息6.显示课程信息**\n");printf("** 7.退出**\n");printf("**********************************************\n");scanf("%d",&i);switch(i){case 1: input3();break;case 2:gengxin();break;case 3:xianshi();goto loop;case 4: chaxun();goto loop;case 5: printf1();goto loop;case 6: printf2();goto loop;case 7:break;default:printf("error");break;}}void input1()//录入结构体stu1[]{int i;FILE *fp;if((fp=fopen("A.txt","r"))==NULL){printf("can not open file\n");exit(0);}/* printf(" 学号姓名性别班级\n");*/for(i=0;i<=5;i++){fscanf(fp,"%s%s%s%s",&stu1[i].num,&stu1[i].name,&stu1[i].sex,&stu1[i].cls);/*printf("%-13s %-10s %-5s %-20s\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i] .cls);*/}fclose(fp);}void input2()//录入结构体stu2[]{int i;FILE *fp;if((fp=fopen("B.txt","r"))==NULL){printf("can not open file\n");exit(0);}for(i=0;i<=5;i++){fscanf(fp,"%s%s%d",&stu2[i].counum,&stu2[i].counam,&stu2[i].credit);}fclose(fp);}void input3()//录入成绩{FILE *fp;fp=fopen("C.txt","w");int a,i,j,k;float cetss;char number[13],cnum[6],mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){printf("请输入要录入学生成绩的个数\n");scanf("%d",&a);for(i=1;i<=a;i++){printf("请输入要录入的第%d同学的学号:",i);scanf("%s",number);printf("请输入要录入的第%d同学的课程号:",i);scanf("%s",cnum);for(j=0;j<=5;j++)//学号{if((strcmp(number,stu1[j].num)==0))break;}if(j<=5){for(k=0;k<=5;k++)//课程号{if(strcmp(cnum,stu2[k].counum)==0){printf("请输入要录入同学的成绩:");scanf("%f",&cetss);fprintf(fp,"%s %s %f\n",number,cnum,cetss);break;}}}if(j>5||k>5){printf("Error,please input again");i=i-1;}printf("录入成功\n");}}else{printf("密码错误\n");}}void output()// 录入结构体stu3[]{int i;FILE *fp=fopen("C.txt","r");for(i=0;i<n;i++){fscanf(fp,"%s%s%f",&stu3[i].num,&stu3[i].counum,&stu3[i].results);/*printf("%s%s%f\n",stu3[i].num,stu3[i].counum,stu3[i].results);*/ }fclose(fp);}void xianshi()// 显示成绩{int i,j;for(i=0;i<n;i++){for(j=0;j<6;j++){if((strcmp(stu3[i].num,stu1[j].num))==0)printf("%s\t",stu1[j].name);}for(j=0;j<6;j++){if(strcmp(stu3[i].counum,stu2[j].counum)==0)printf("%s\t",stu2[j].counam);}printf("%3.1f\n",stu3[i].results);}}void chaxun()//查询功能{char number[13],c;int i,j,k,a,b,d;while((c=getchar())!='Q'){a=0,b=0;//a记录学分b记录学科printf("请输入要查询同学的学号\n");scanf("%s",number);for(i=0;i<n;i++){if(strcmp(number,stu3[i].num)==0){printf("学号:%s\t",stu3[i].num);for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){printf("姓名:%s\n",stu1[j].name);}}break;}}d=i;for(i=0;i<n;i++)if(strcmp(number,stu3[i].num)==0){b=b+1;for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<6;k++){if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;}break;}}if(stu3[i].results>=60){a=a+stu2[k].credit;printf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,stu2[k].credit);}elseprintf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,0);}if(d<n){printf("共修%d科\t\t实得总学分:%d\n",b,a);}else{printf("学号输入错误\n");}getchar();printf("退出请按Q+回车,继续查询请按回车键");}}void gengxin()//更新信息,删除C.txt中无用信息{FILE *fp;int i,j,k;char mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){fp=fopen("C.txt","w");for(i=0;i<n;i++){for(j=0;j<6;j++)if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<=5;k++)if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;if(k<=5){fprintf(fp,"%s %s %f\n",stu3[i].num,stu3[i].counum,stu3[i].results);}}}printf("更新C.txt成功\n");fclose(fp);}else{printf("密码错误\n");}}void printf1()//显示学生信息{int i;printf(" 学号姓名性别班级\n");for(i=0;i<=5;i++){printf("%-13s%-10s%-5s %-20s\n\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i].cls);}}void printf2()//显示课程信息{int i;printf(" 课程编号课程名称学分\n");for(i=0;i<=5;i++){printf("%-6s%-20s %-4d\n\n",stu2[i].counum,stu2[i].counam,stu2[i].credit);}}。
C语言课程设计——学生管理系统源代码
C语言课程设计——学生管理系统源代码#include〈stdio。
h>#include〈stdlib。
h〉#include<string。
h〉#include〈conio.h>#define MY1 printf(”学号\t姓名\t性别\t年龄\t生日”)#define MY2 printf(”\n%d %6s %4s\t%2d %8d%2d%2d \n",s[i].num,s[i].name,s[i]。
sex,s[i]。
age,s[i]。
a。
year,s[i].a。
month,s[i].a.day)#define MY3 printf(”家庭住址联系方式高数英语大物总成绩")#define MY4 printf(”\n%4s %4s %2d %2d %2d %2d\n”,s[i]。
address,s[i]。
tel,s[i].c。
gao,s[i]。
c.ying,s[i].c.wu,s[i].c.total)#define MAX 30int i;int sum;/*时间结构体类型*/struct date{int year;int month;int day;}a;/*学生成绩结构体类型*/struct score{int gao;int ying;int wu;int total;}c;/*学生信息结构体类型*/struct s_message{int num;char name[20];char sex[5];int age;struct date a;char address[50];char tel [11];struct score c;}s[MAX];/*保存学生信息模块*/int i;FILE*fp;if((fp=fopen(”D:\\s。
txt",”wb”))==NULL){printf(”reading file is wrong!\n”);return;}for (i=0;i<sum;i++){if(fwrite(&s[i],sizeof(struct s_message),1,fp)!=1)printf(”writing file is wrong!\n”);}fclose(fp);}/*读取学生信息模块*/int read_message(){FILE *fp;int i=0;if((fp=fopen("D:\\s。
学生成绩管理系统(数据结构C语言版源代码)
学生成绩管理系统(数据结构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语⾔源代码#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语言学生管理系统代码
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语言学生信息管理系统(完整版)
#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语言课程设计任务书3题目:学生成绩管理系统功能:学生成绩管理系统,每个学生是一个记录,包括学号,姓名,性别,3门课程成绩。
系统要求实现以下功能:1、信息录入:录入学生成绩信息(包括学生学号、姓名、各门课程的成绩等);2、信息查询:输入学号,查询学生各门课程的成绩,并显示。
3、排序:按各门课程的成绩平均分进行排序,并显示。
4、信息删除与修改——输入学号,删除该学生的成绩信息。
098班陈焕流程图:主要源程序代码#include<iostream.h>#include<string.h>#include<fstream.h>class stu{char name[20];double math,chinese,english,average,sum; public:stu(){}stu(char n[20],double ma,double chin,double eng) {strcpy(name,n);math=ma;chinese=chin;english=eng;}double getsum(){sum=chinese+english+math;return sum;}double getaver(){average=getsum()/3;return average;}friend void main();};void main(){cout<<"请选择您需要的操作!"<<endl;cout<<"操作:"<<endl;cout<<"(0)数据录入"<<endl;cout<<"(1)增加人员"<<endl;cout<<"(2)删除人员"<<endl;cout<<"(3)修改数据"<<endl;cout<<"查询:"<<endl;cout<<"(4)按总成绩查询"<<endl;cout<<"(5)按姓名查询"<<endl;cout<<"(6)输出所有学生的数据"<<endl;cout<<"成绩名词"<<endl;cout<<"(7)按总分查询排名"<<endl;cout<<"(8)按语文查询排名"<<endl;cout<<"(9)按数学查询排名"<<endl;cout<<"(y)按英语查询排名"<<endl;cout<<"选择相关操作请输入相对的括号里的阿拉伯数字!"<<endl;char p;char w;stu *s[50];ofstream *file[50];int i=0;int j=0;bool flag2=0;do{cin>>p;if((p>='0'&&p<='10'))flag2=1;elsecout<<"指令错误!请重新输入:"<<endl;}while(flag2==0);do{switch(p){case '0':{char c;char name[20];double math,chinese,english;do{cout<<"请输入姓名"<<endl;cin>>name;cout<<"请输入数学成绩:"<<endl;cin>>math;cout<<"请输入语文成绩:"<<endl;cin>>chinese;cout<<"请输入外语成绩:"<<endl;cin>>english;file[j]=new ofstream("d:\\document",ios::ate);*file[j]<<"姓名"<<name<<"数学成绩"<<math<<"语文成绩"<<chinese<<"外语成绩"<<english<<endl;j++;s[i]=new stu(name, math, chinese, english);cout<<"数据录入成功,想继续录入吗(y/n)"<<endl; cin>>c;flag2=0;do{if(c!='y'&&c!='n'){cout<<"指令错误!请重新输入!"<<endl;cin>>c;}elseflag2=1;}while(flag2==0);}while(c=='y');break;}case '4':{double t;char c;do{int flag1=0;cout<<"请输入你要查询学生的总成绩"<<endl; cin>>t;for(int q=0;q<i;q++){if(s[q]->getsum()==t){flag1=1;cout<<"您要查询的学生是:"<<(*s[q]).name<<endl; }}if(flag1==0)cout<<"对不起!您要查询的学生不存在!"<<endl; cout<<"您想继续查询吗?(y/n)"<<endl;cin>>c;if(c!='y'&&c!='n'){cout<<"指令错误!请重新输入!"<<endl;cin>>c;}while(c=='y');break;}case '5':{char n[20];int j=0;char c;do{int flag=0;cout<<"请输入你要查询的学生姓名"<<endl;cin>>n;for(int j=0;j<i;j++){if(strcmp(n,(*s[j]).name)==0){flag=1;cout<<"您要查询的学生是:"<<(*s[j]).name<<endl;cout<<(*s[j]).name<<"的总成绩成绩是"<<(*s[j]).getsum()<<endl<<"平均成绩是:"<<(*s[j]).getaver()<<endl;}}if(flag==0)cout<<"对不起!您要查询的学生不存在!"<<endl;cout<<"您想继续查询吗?(y/n)"<<endl;cin>>c;if(c!='y'&&c!='n'){cout<<"指令错误!请重新输入!"<<endl;cin>>c;}}while(c=='y');break;}case '1':{char name[20];double math,chinese,english;char c;do{cout<<"请输入您要增加的学生的姓名:"<<endl;cin>>name;cout<<"请输入数学成绩:"<<endl;cin>>math;cout<<"请输入语文成绩:"<<endl;cin>>chinese;cout<<"请输入外语成绩:"<<endl;cin>>english;file[j]=new ofstream("d:\\document",ios::ate);*file[j]<<"姓名"<<name<<"数学成绩"<<math<<"语文成绩"<<chinese<<"外语成绩"<<english<<endl;j++;s[i]=new stu(name, math, chinese, english);i++;cout<<"数据录入成功,想继续录入吗(y/n)"<<endl;cin>>c;if(c!='y'&&c!='n'){cout<<"指令错误!请重新输入!"<<endl;cin>>c;}}while(c=='y');break;}case '2':{char name[20];bool flag3=0;char c;do{cout<<"请输入您要删除的学生姓名:"<<endl;cin>>name;for(int h=0;h<i;h++){if(strcmp(name,s[h]->name)==0){flag3=1;i--;do{s[h]=s[h+1];h++;}while(h<=i);}}if(flag3==0)cout<<"您要求删除的对象本来就不存在!请检查输入的正确性!"; cout<<"要继续删除吗?(y/n)"<<endl;cin>>c;if(c!='y'&&c!='n'){cout<<"指令错误!请重新输入!"<<endl;cin>>c;}}while(c=='y');break;}case '3':{char name[20];double mat,chin,eng;flag2=0;char c;do{cout<<"请输入您要修改的学生的姓名:"<<endl;cin>>name;for(int h=0;h<i;h++){if(strcmp(name,s[h]->name)==0){flag2=1;cout<<"请输入新的数学成绩:"<<endl;cin>>mat;cout<<"请输入新的语文成绩:"<<endl;cin>>chin;cout<<"请输入新的外语成绩:"<<endl;cin>>eng;s[h]->chinese=chin;s[h]->math=mat;s[h]->english=eng;cout<<"数据修改成功!";}}if(flag2==0){cout<<"您要修改的学生本来就不存在!请检查重新输入!"<<endl; }cout<<"想继续修改吗(y/n)"<<endl;cin>>c;if(c!='y'&&c!='n'){cout<<"指令错误!请重新输入!"<<endl;cin>>c;}}while(c=='y');break;}case '6':{cout<<"本系统所有学生数据如下:"<<endl;if(i==0)cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl; for(int k=0;k<i;k++){cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math<<"外语:"<<" "<<s[k]->english<<"总分:"<<" "<<(*s[k]).getsum() <<"平均分:"<<" "<<(*s[k]).getaver()<<endl;}break;}case '7':{int t;stu b;cout<<"本系统所以学生排名如下:"<<endl;for(int x=0;x<i-1;x++){t=x;for(int y=x+1;y<i;y++){if((s[t]->getsum())<(s[y]->getsum()))t=y;if(t!=x){b=*s[x];*s[x]=*s[t];*s[t]=b;}}}if(i==0)cout<<"管理系统中没有录入数据或者数据已经被删除!";for(int k=0;k<i;k++){cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math<<"外语:"<<" "<<s[k]->english<<"总分:"<<" "<<s[k]->getsum() <<"平均分:"<<" "<<s[k]->getaver()<<endl;}break;}case '8':{int t;stu b;cout<<"本系统所以学生语文排名如下:"<<endl;for(int x=0;x<i-1;x++){t=x;for(int y=x+1;y<i;y++){if((s[t]->chinese)<(s[y]->chinese))t=y;if(t!=x){b=*s[t];*s[t]=*s[x];*s[x]=b;}}}if(i==0)cout<<"管理系统中没有录入数据或者数据已经被删除!";for(int k=0;k<i;k++){cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math<<"外语:"<<" "<<s[k]->english<<"总分:"<<" "<<s[k]->getsum() <<"平均分:"<<" "<<s[k]->getaver()<<endl;}break;}case '9':{int t;stu b;cout<<"本系统所以学生数学排名如下:"<<endl;for(int x=0;x<i-1;x++){t=x;for(int y=x+1;y<i;y++){if((s[t]->math)<(s[y]->math))t=y;if(t!=x){b=*s[t];*s[t]=*s[x];*s[x]=b;}}}if(i==0)cout<<"管理系统中没有录入数据或者数据已经被删除!";for(int k=0;k<i;k++){cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math<<"外语:"<<" "<<s[k]->english<<"总分:"<<" "<<s[k]->getsum() <<"平均分:"<<" "<<s[k]->getaver()<<endl;}break;}case 'y':{int t;stu b;cout<<"本系统所以学生英语排名如下:"<<endl;for(int x=0;x<i-1;x++){t=x;{if((s[t]->english)<(s[y]->english))t=y;if(t!=x){b=*s[t];*s[t]=*s[x];*s[x]=b;}}}if(i==0)cout<<"管理系统中没有录入数据或者数据已经被删除!";for(int k=0;k<i;k++){cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math<<"外语:"<<" "<<s[k]->english<<"总分:"<<" "<<s[k]->getsum()<<"平均分:"<<" "<<s[k]->getaver()<<endl;}}break;}cout<<"您想继续进行其他操作吗?(y/n)"<<endl;bool flag4=0;do{cin>>w;if(w!='y'&&w!='n')cout<<"指令错误!请重新输入!"<<endl;elseflag4=1;}while(flag4==0);if(w=='y')cout<<"请输入操作代码(0 录入/4 按总分查询/5 按姓名查询/1 增加人员/2 删除人员/3 修改数据/6 显示所有成员数据/7 按总分排名/8 按语文排名/9按数学排名/y按英语排名)"<<endl;cin>>p;}while(w=='y');{delete s[x];cout<<"delete all members!"<<endl;}}测试情况及调试中问题与解决方案:测试情况失败好几次。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include<stdio.h>#include<dos.h>#define N sizeof(struct STH)#define GESHI "%-10ld%-10s%-5s%-4d/%-2d/%-4d%-12s%-12s%s\n"#define PRINTF "学号性别生日系别班级家庭住址\n"struct STH* readfile();/*声明*/int insert(struct STH**);int n=0;struct dt{int year; /*全局变量*/int month;int day;};struct STH{long num; /*学号不能以0开头*/char name[9];char sex[5];struct dt birth;char xi[20];char ban[20];char add[30];struct STH* next;}*head;/*输入模块*/input_message(){char ch;int flag=1;do{if(insert(&head)!=0)n++; /*计数*/elseprintf("\n有相同的的学号!");printf("\n是否继续?(y/n)");getchar();scanf("%c",&ch);if(ch=='y'||ch=='Y'){printf("\n继续!");getch();flag=1;/*标志程序不结束*/}elseflag=0;}while(flag==1);save_message();printf("按任意键继续...");getch();}/*insert()模块*/ /*被输入和插入模块所调用*/int insert(struct STH**h){struct STH *p,*p0;p=(struct STH*)malloc(N);printf("\n请输入学号:");scanf("%ld",&p->num);printf("\n请输入:");scanf("%s",p->name);printf("\n请输入性别:");getchar(); /*取走上一个留下来得‘\n’*/scanf("%s",p->sex);printf("\n请输入生日(年月日,用回车隔开):\n");scanf("%d%d%d",&p->birth.year,&p->birth.month,&p->birth.day);printf("\n请输入系别:");scanf("%s",p->xi);printf("\n请输入班级:");scanf("%s",p->ban);printf("\n请输入家庭住址:");scanf("%s",p->add);p->next=NULL;if(*h==NULL){*h=p;return 1;}p0=*h;if(p0->num>p->num){p->next=p0;*h=p;return 1;}while(p0->next!=NULL&&p0->next->num<p->num)p0=p0->next;if(p0->next==NULL){p0->next=p;return 1;}else if(p0->next->num==p->num){free(p); /*有相同数据输入失败*/return 0;}else{p->next=p0->next;p0->next=p;return 1;}}/*读文件模块*/ /*读文件模块中创建了一个新的链表,其返回值为新链表的头指针*/struct STH *readfile(){FILE *fp;struct STH *p,*p0;char ch;int i;if((fp=fopen("STH.txt","r"))==NULL){printf("\n不能读取文件!\n");return NULL;}/*注意要该*/head=p=p0=(struct STH *)malloc(N);fscanf(fp,"%d",&n);fscanf(fp,"%c",&ch); /*为了使学号和信息个数分开加入一个‘/’*/fscanf(fp,"%ld%s%s%d%d%d%s%s%s",&p->num,p->name,p->sex,&p->birth.year,&p->birth. month,&p->birth.day,p->xi,p->ban,p->add);p->next=NULL;i=1; /*如果只有一个数时跳出*/if(n!=1){do{p=(struct STH *)malloc(N);fscanf(fp,"%ld%s%s%d%d%d%s%s%s",&p->num,p->name,p->sex,&p->birth.year, &p->birth.month,&p->birth.day,p->xi,p->ban,p->add);p0->next=p;p0=p;i++;}while(i<n);p0->next=NULL;}fclose(fp);return head;}/*插入模块*/insert_message(){struct STH *p;int flag=1;char ch;head=readfile();do{if(insert(&head)!=0){n++;save_message();printf("");} /*计数*/else{printf("\n添加失败!\n有相同的的学号!");save_message();getch();}printf("\n是否继续?(y/n)");getchar();ch=getchar();if(ch=='y'||ch=='Y'){printf("\n继续!");flag=1;/*标志程序不结束*/}elseflag=0;}while(flag==1);printf("\n按任意键继续...");getch();}/*修改模块*/renew_message(){struct STH *p;int i,flag=1;long num;p=head=readfile();if(head==NULL){printf("读文件有误!");getch();}else{printf("\n请按输入要修改的学生的学号:");scanf("%ld",&num);for(i=0;i<n;i++){if(p->num==num){p->num=num;printf("\n已找到要%ld号学生的信息!\n",num);printf("原为%s 要修改为:\n",p->name);scanf("%s",p->name);printf("原性别为%s 要修改为:\n",p->sex);scanf("%s",p->sex);printf("原生日为%d/%d/%d 要修改为:\n",p->birth.year,p->birth.month,p->birth.day);scanf("%d%d%d",&p->birth.year,&p->birt h.month,&p->birth.day);printf("原系别为%s 要修改为:\n",p->xi);scanf("%s",p->xi);printf("原班级为%s 要修改为:\n",p->ban);scanf("%s",p->ban);printf("原家庭住址为%s 要修改为:\n",p->add);scanf("%s",p->add);printf("你所更改后的信息为:\n");printf(PRINTF);printf(GESHI,p->num,p->name,p->sex, p->birth.year,p->birth.month,p->birth.day,p->xi,p->ban,p->add);printf("\n按任意键退出!\n");getch();flag=1;break;}elsep=p->next;}if(flag!=1)printf("无此人信息!\n");elsesave_message();getch();}}/*删除模块*/delete_message(){int flag;long num;char ch;struct STH*p,*p0;p0=p=head=readfile();if(head==NULL){printf("文件读取出错!");getch();}else{printf("请输入要删除学生的学号:\n");scanf("%ld",&num);if(p0->num==num){head=p0->next;free(p0);flag=1;n--; /*学生数减一*/}p=p0->next;while(p!=NULL){if(p->num==num){p0->next=p->next;free(p);flag=1;n--;}else{p0=p;p=p->next;}}if(p->next==NULL)flag=0;if(flag==1){printf("\n永久删除%ld号学生的信息?(y/n)",num);getchar();ch=getchar();if(ch=='y'||ch=='Y')save_message();else{printf("\n撤消删除!");getch();}}elseprintf("\n删除失败!");getch();}}/*查询模块*/inquire_message(){int i,flag=0;long num;struct STH *p;p=head=readfile();if(head==NULL){printf("文件读取出错!");getch();}else{printf("请输入要查询学生的学号:\n");scanf("%ld",&num);for(i=0;i<n;i++){if(p->num==num){printf("\n信息已找到:\n");getch();clrscr();printf("****************************** ****FOUND*********************************\n");printf("------------------------------------------------------------------------\n\n");printf(PRINTF);printf(GESHI,p->num,p->name,p->sex, p->birth.year,p->birth.month,p->birth.day,p->xi,p->ban,p->add);printf("\n------------------------------------------------------------------------\n");printf("****************************** *****END**********************************\n");flag=1;break;}elsep=p->next;}if(flag==0)printf("\n无此人信息!");elseprintf("\n显示完毕!\按任意键返回主菜单......");getch();}}/*显示模块*/output_message(){int i=0;struct STH*p;p=head=readfile();if(head==NULL){printf("文件读取出错!");getch();}else{clrscr();printf("\n************************************STUDENT* ***********************************\n");printf("-------------------------------------------------------------------------------\n");printf(PRINTF);while(i<n){printf(GESHI,p->num,p->name,p->sex,p->birth .year,p->birth.month,p->birth.day,p->xi,p->ban,p->add);p=p->next;i++;}printf("-------------------------------------------------------------------------------\n");printf("**************************************END*** ***********************************\n");printf("\n显示完毕!\n共%d条信息.\n按任意键返回主菜单......",n);getch();}}/*存档模块*/save_message(){FILE *fp;int i;struct STH*p;p=head;if((fp=fopen("STH.txt","w"))==NULL){printf("读文件错误!!");exit(0);}fprintf(fp,"%d",n);fprintf(fp,"%c",'/');/*注意要该*/for(i=0;i<n;i++){fprintf(fp,"%ld %s %s %d %d %d %s %s %s ",p->num,p->name,p->sex,p->birth.year,p->birth.month,p->birth.day,p->xi,p->ban,p->add);p=p->next;}fclose(fp);printf("\n信息已经保存在STH.txt文件中!");getch();}/*主函数*/void main(void){int choice;char ch;FILE *fp;struct date d;getdate(&d);if((fp=fopen("STH.txt","r"))==NULL){fp=fopen("STH.txt","w");fprintf(fp,"%d",0);fclose(fp);}else{fscanf(fp,"%d",&n);fclose(fp);}clrscr();printf("制作人:通工0501 艺凡");printf("\n\n\n");printf(" ***************************** ********************* \n");printf("欢迎进入学生户籍系统 \n\n");printf(" 1 创建记录\n");printf(" 2 添加记录\n");printf(" 3 查找记录\n");printf(" 4 删除记录\n");printf(" 5 修改记录\n");printf(" 6 显示全部信息\n");printf(" 0 退出程序\n");printf(" ***************************** ********************* \n");printf("%d年%d月%d日",d.da_year,d.da_mon,d.da_day);printf(" \n 请选择(0-6):");scanf("%d",&choice);if(n==0) /*记录为空时不让其进行其他操作*/{while(choice<0||choice>1){printf("记录为空,无法操作此项!");printf("请重新输入:(0或1)\n");scanf("%d",&choice);}}else{while(choice<0||choice>6){printf("输入有误!\n 请重新输入:\n");scanf("%d",&choice);}}do{switch(choice){case 1:input_message();break;case 2:insert_message();break;case 3:inquire_message();break;case 4:delete_message();break;case 5:renew_message();break;case 6:output_message();break;case 0:break;}printf("\n按任意键返回主菜单!");getchar();ch='y';if(ch=='Y'||ch=='y'){clrscr();printf("制作人:通工0501 艺凡");printf("\n\n\n");printf(" ************* ************************************* \n");printf("欢迎进入学生户籍系统 \n\n");printf("1 创建记录\n");printf("2 添加记录\n");printf("3 查找记录\n");printf("4 删除记录\n");printf("5 修改记录\n");printf("6 显示全部信息\n");printf("0 退出程序\n");printf(" ************* ************************************* \n");printf("%d年%d月%d日",d.da_year,d.da_mon,d.da_day);printf(" \n 请选择(0-6):");scanf("%d",&choice);}}while(choice!=0);printf("以上信息已经保存在STH.txt中!\n");}。