init.c 1.2 KB
Newer Older
Gongzi-Yu's avatar
Gongzi-Yu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#include <stdio.h>

typedef struct
{
	char xh[10];
	char xm[20];
	char xb[3];
	int nl;
}Student;

typedef struct
{
	char kh[10];
	char km[25];
	float xf;
}Course;

typedef struct
{
	char xh[10];
	char kh[10];
	float cj;
}Select;

typedef struct
{
	char xh[10];
	char xm[20];
	float cj[30];
	float zpj;
	float zxf;
}Score;


void instud(Student slist[],int count)
{
	FILE *fp;
	char studentname[20];
	int i;

	printf("Pealse input studentname:\n");
	scanf("%s",studentname);
	fp = fopen(studentname, "r");
	if(fp==NULL) fp = fopen("de_student.dat","r");
	for (i=0;i<count;i++) fread(&slist[i],sizeof(Student),1,fp);
	fclose(fp);
}

void incourse(Course clist[],int count)
{
	FILE *fp;
	char coursename[20];
	int i;

	printf("Pealse input coursename:\n");
	gets(coursename);
	fp = fopen(coursename, "r");
	if(fp==NULL) fp = fopen("de_course.txt","r");
	for (i=0;i<count;i++) fread(&clist[i],sizeof(Course),1,fp);
	fclose(fp);
}

void incjlist(Score sclist[],int count)
{
	FILE *fp;
	char scorename[20];
	int i;

	printf("Pealse input studentname:\n");
	gets(scorename);
	fp = fopen(scorename, "r");
	if(fp==NULL) fp = fopen("de_scorse.txt","r");
	for (i=0;i<count;i++) fread(&sclist[i],sizeof(Score),1,fp);
	fclose(fp);
}