C语言实训设计-学生信息
2、教学事务管理系统该系统在磁盘上存储如下信息:1。注册信息,每个学期的注册信息应包括每个已注册学生的班级代号、学号、姓名、注册的学期。2。选课信息。包括已注册的每个学生...
2、教学事务管理系统
该系统在磁盘上存储如下信息:
1。注册信息,每个学期的注册信息应包括每个已注册学生的班级代号、学号、姓名、注册的学期。
2。选课信息。包括已注册的每个学生每个学期所选课程。本程序仅限一年级2个学期。
3。成绩。 每个学生所选的课程的考核成绩,包括补考成绩。
该系统的功能:
1。能输入注册信息,选课信息和成绩。
2。能输出一下表格:
1)分班的某门课程不及格名单(含学号,姓名,成绩)
2)某门课程全年级前5名的学号,姓名,成绩
3)某门课程的选修者名单;
4)某个学生本学期的成绩单
5)某门课程每个班的总平均粉(从高到低排列)
6)某门课程某班的成绩单(按学号排列)
求救啊 展开
该系统在磁盘上存储如下信息:
1。注册信息,每个学期的注册信息应包括每个已注册学生的班级代号、学号、姓名、注册的学期。
2。选课信息。包括已注册的每个学生每个学期所选课程。本程序仅限一年级2个学期。
3。成绩。 每个学生所选的课程的考核成绩,包括补考成绩。
该系统的功能:
1。能输入注册信息,选课信息和成绩。
2。能输出一下表格:
1)分班的某门课程不及格名单(含学号,姓名,成绩)
2)某门课程全年级前5名的学号,姓名,成绩
3)某门课程的选修者名单;
4)某个学生本学期的成绩单
5)某门课程每个班的总平均粉(从高到低排列)
6)某门课程某班的成绩单(按学号排列)
求救啊 展开
3个回答
展开全部
看在你看鲁路修的份儿上,我提供你部分代码,好好儿努力吧~
//*----------------classE----------------*//
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"conio.h"
#define Len (0-sizeof(stu))
#define Max_L 200
typedef struct student
{int num;
char name[20];
int math;
int computer;
int physics;
int english;
}stu;
typedef struct list
{stu *head;
int length;
}L_list;
FILE *fp;
void open_file()
{if((fp=fopen("student.dat","rb+"))==NULL)
{printf("student.dat missing!\n");
exit(0);
}
}
void menu()
{printf("1.insert a student\n");
printf("2.delete a student\n");
printf("3.search the student\n");
printf("4.change the information of a student\n");
printf("5.output all the information of the students\n");
printf("chosen:");
}
void insert()
{
stu s;
fseek(fp,0,2);
printf("exit when type in'#',each information divided by 'space' key.\n");
do
{scanf("%d %s %d %d %d %d",&s.num,s.name,&s.math,&s.computer,&s.physics,&s.english);
fwrite(&s,sizeof(stu),1,fp);
fflush(stdin);
}
while(getch()!='#');
}
void num()
{stu s;
int n;
scanf("%d",&n);
do
{fread(&s,sizeof(stu),1,fp);
if(feof(fp))
{printf("No student have a number of 0%d here\n",n);
return;
}
}
while(s.num!=n);
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
fseek(fp,Len,1);
}
void name()
{stu s;
char n[20];
scanf("%s",n);
do
{fread(&s,sizeof(stu),1,fp);
if(feof(fp))
{printf("No %s here\n",n);
return;
}
}
while(strcmp(n,s.name)!=0);
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
fseek(fp,Len,1);
}
void search()
{rewind(fp);
fflush(stdin);
char c;
printf("1.search by number\n");
printf("2.search by name\n");
printf("chosen:");
c=getchar();
switch(c)
{case'1':num();break;
case'2':name();break;
default:printf("fuck!\n");
}
}
void change()
{stu s;
search();
printf("please type in the changed information!\n");
scanf("%d %s %d %d %d %d",&s.num,s.name,&s.math,&s.computer,&s.physics,&s.english);
fwrite(&s,sizeof(stu),1,fp);
fseek(fp,Len,1);
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
}
void output()
{rewind(fp);
stu s;
for(;;)
{
fread(&s,sizeof(stu),1,fp);
if(feof(fp))break;
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
}
}
bool initlist(L_list *L)
{L->head=(stu *)malloc(Max_L*sizeof(stu));
if(!L->head)return 0;
L->length=0;
return 1;
}
void del()
{
L_list student;
stu s,*H;
initlist(&student);
H=student.head;
search();
fread(&s,sizeof(stu),1,fp);
rewind(fp);
for(;;)
{
fread(H,sizeof(stu),1,fp);
if(H->num!=s.num)
H++;
if(feof(fp))break;
student.length++;
}
fclose(fp);
if((fp=fopen("student.dat","wb"))==NULL)
{printf("error");
exit(0);
}
H=student.head;
fwrite(H,sizeof(stu),student.length,fp);
fclose(fp);
open_file();
}
void class_system()
{char c;
do
{
fflush(stdin);
system ("cls");
menu();
c=getchar();
switch (c)
{case '1':system("cls");insert();break;
case '2':system("cls");del();break;
case '3':system("cls");search();break;
case '4':system("cls");change();break;
case '5':system("cls");output();break;
default:printf("fuck!\n");
}
printf("do you want to coutinue,Y/N?\n");
fflush(stdin);
c=getchar();
}
while(c=='y');
fclose(fp);
}
void main()
{
open_file();
class_system();
}
//*---------------------------classF--------------------*//
#include"stdio.h"
#include"stdlib.h"
typedef struct student
{int num;
char name[20];
int math;
int computer;
int physics;
int english;
}stu;
void input()
{FILE * fp;stu s;
if((fp=fopen("student.dat","wb"))==NULL)
{printf("student.dat missing!\n");
exit(0);
}
do
{scanf("%d %s %d %d %d %d",&s.num,s.name,&s.math,&s.computer,&s.physics,&s.english);
fwrite(&s,sizeof(stu),1,fp);
fflush(stdin);}
while(getchar()!='#');
fclose(fp);
}
void main()
{input();
}
//*classF实现了文件的初始化,classE是对文件进行操作的exe文件,选课系统,排序功能你自己实现1下,部分代码就算是个参考吧,实际还是你自己编来得比较快*//
//*----------------classE----------------*//
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"conio.h"
#define Len (0-sizeof(stu))
#define Max_L 200
typedef struct student
{int num;
char name[20];
int math;
int computer;
int physics;
int english;
}stu;
typedef struct list
{stu *head;
int length;
}L_list;
FILE *fp;
void open_file()
{if((fp=fopen("student.dat","rb+"))==NULL)
{printf("student.dat missing!\n");
exit(0);
}
}
void menu()
{printf("1.insert a student\n");
printf("2.delete a student\n");
printf("3.search the student\n");
printf("4.change the information of a student\n");
printf("5.output all the information of the students\n");
printf("chosen:");
}
void insert()
{
stu s;
fseek(fp,0,2);
printf("exit when type in'#',each information divided by 'space' key.\n");
do
{scanf("%d %s %d %d %d %d",&s.num,s.name,&s.math,&s.computer,&s.physics,&s.english);
fwrite(&s,sizeof(stu),1,fp);
fflush(stdin);
}
while(getch()!='#');
}
void num()
{stu s;
int n;
scanf("%d",&n);
do
{fread(&s,sizeof(stu),1,fp);
if(feof(fp))
{printf("No student have a number of 0%d here\n",n);
return;
}
}
while(s.num!=n);
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
fseek(fp,Len,1);
}
void name()
{stu s;
char n[20];
scanf("%s",n);
do
{fread(&s,sizeof(stu),1,fp);
if(feof(fp))
{printf("No %s here\n",n);
return;
}
}
while(strcmp(n,s.name)!=0);
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
fseek(fp,Len,1);
}
void search()
{rewind(fp);
fflush(stdin);
char c;
printf("1.search by number\n");
printf("2.search by name\n");
printf("chosen:");
c=getchar();
switch(c)
{case'1':num();break;
case'2':name();break;
default:printf("fuck!\n");
}
}
void change()
{stu s;
search();
printf("please type in the changed information!\n");
scanf("%d %s %d %d %d %d",&s.num,s.name,&s.math,&s.computer,&s.physics,&s.english);
fwrite(&s,sizeof(stu),1,fp);
fseek(fp,Len,1);
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
}
void output()
{rewind(fp);
stu s;
for(;;)
{
fread(&s,sizeof(stu),1,fp);
if(feof(fp))break;
printf("number:0%d\nname:%s\nmath:%d\ncomputer:%d\nphysics:%d\nenglish:%d\n",s.num,s.name,s.math,s.computer,s.physics,s.english);
}
}
bool initlist(L_list *L)
{L->head=(stu *)malloc(Max_L*sizeof(stu));
if(!L->head)return 0;
L->length=0;
return 1;
}
void del()
{
L_list student;
stu s,*H;
initlist(&student);
H=student.head;
search();
fread(&s,sizeof(stu),1,fp);
rewind(fp);
for(;;)
{
fread(H,sizeof(stu),1,fp);
if(H->num!=s.num)
H++;
if(feof(fp))break;
student.length++;
}
fclose(fp);
if((fp=fopen("student.dat","wb"))==NULL)
{printf("error");
exit(0);
}
H=student.head;
fwrite(H,sizeof(stu),student.length,fp);
fclose(fp);
open_file();
}
void class_system()
{char c;
do
{
fflush(stdin);
system ("cls");
menu();
c=getchar();
switch (c)
{case '1':system("cls");insert();break;
case '2':system("cls");del();break;
case '3':system("cls");search();break;
case '4':system("cls");change();break;
case '5':system("cls");output();break;
default:printf("fuck!\n");
}
printf("do you want to coutinue,Y/N?\n");
fflush(stdin);
c=getchar();
}
while(c=='y');
fclose(fp);
}
void main()
{
open_file();
class_system();
}
//*---------------------------classF--------------------*//
#include"stdio.h"
#include"stdlib.h"
typedef struct student
{int num;
char name[20];
int math;
int computer;
int physics;
int english;
}stu;
void input()
{FILE * fp;stu s;
if((fp=fopen("student.dat","wb"))==NULL)
{printf("student.dat missing!\n");
exit(0);
}
do
{scanf("%d %s %d %d %d %d",&s.num,s.name,&s.math,&s.computer,&s.physics,&s.english);
fwrite(&s,sizeof(stu),1,fp);
fflush(stdin);}
while(getchar()!='#');
fclose(fp);
}
void main()
{input();
}
//*classF实现了文件的初始化,classE是对文件进行操作的exe文件,选课系统,排序功能你自己实现1下,部分代码就算是个参考吧,实际还是你自己编来得比较快*//
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询