diff --git a/student.txt b/student.txt new file mode 100644 index 0000000..ddd806e Binary files /dev/null and b/student.txt differ diff --git a/未命名1.cpp b/未命名1.cpp new file mode 100644 index 0000000..d5b65ee --- /dev/null +++ b/未命名1.cpp @@ -0,0 +1,365 @@ +#include +#include +#include +#include +#include +#define LEN sizeof(struct student) +#define FORMAT "\t%s\t%s\t\t%d\n" //궨ʽ +#define DATA peo[i].name,peo[i].num,peo[i].score //궨ṹ壨 + +struct student +{ + char name[100]; + char num[15]; + int score; +}; +struct student peo[100]; +void addman(); +void queryman(); +void delman(); +void update(); +void outputman(); +void menu(); + +void menu()//˵ģ +{ + system("cls"); + printf("\n\t\t*********CԳɼ¼*********\n"); + printf("\t\t-------------------------------\n"); + printf("\t\t 1.ѧϢ \n"); + printf("\t\t 2.ѯѧϢ \n"); + printf("\t\t 3.ɾѧϢ \n"); + printf("\t\t 4.޸ѧϢ \n"); + printf("\t\t 5.ֶѧϢ \n"); + printf("\t\t 0.˳ \n"); + printf("\t\t-------------------------------\n"); + printf("\t\tѡ(0-5):"); +} + +void tou() //бͷ +{ system("cls"); + printf("\n"); + printf("**************ѧϢб*********************\n\n"); + printf("\t\t ѧ\t CԳɼ\n"); +} +void wei() //бβ +{ + printf("\n**********************************************\n\n"); +} + +int main () +{ + int n; + menu(); + scanf("%d",&n); + while(n) + { + switch(n) + { + case 1: + addman(); + system("pause"); + break; + case 2: + queryman(); + system("pause"); + break; + case 3: + delman(); + system("pause"); + break; + case 4: + update(); + system("pause"); + break; + case 5: + outputman(); + system("pause"); + break; + default:break; + } + menu(); + scanf("%d",&n); + } + } + + +void addman() +{ +FILE *p1; + int i,n,count=0; // countΪѧ + if ((p1=fopen("D:\\1\\student.txt","a+"))==NULL) //linkmanļ + { + printf("ܴ򿪴ļ"); + exit(0); + } + while(!feof(p1)) //feofΪļ + { + if(fread(&peo[count],LEN,1,p1)==1) + count++; + } + fclose(p1); //رļ + if(count==0) + printf("\n\t\tѧϢбΪ!\n\n"); + else + { + system("cls"); // + outputman(); + } + if ((p1=fopen("D:\\1\\student.txt","wb"))==NULL)//ԶƷʽlinkmanļ + { + printf("\t\tܴѧϢб\n"); + return; + } + + for(i=0;i