From 764c4492465fc5e510328a7f127e0e7ea288890a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=AD=A3=E8=B4=A2?= <3047498954@qq.com> Date: Wed, 9 Jan 2019 23:43:08 +0800 Subject: [PATCH] third commit --- 删除学生信息、查询信息.c | 136 ++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 删除学生信息、查询信息.c diff --git a/删除学生信息、查询信息.c b/删除学生信息、查询信息.c new file mode 100644 index 0000000..09128ff --- /dev/null +++ b/删除学生信息、查询信息.c @@ -0,0 +1,136 @@ +void reduce() +{ + int i=0,j,k,id; + FILE *fp1,*fp2,*ff; + ff=fopen("b.txt","r"); + fscanf(ff,"%d",&j); + close(ff); + if((fp1=fopen("a.txt","r"))==NULL) + { + printf("file open error"); + exit(0); + } + printf("ҪɾѧϢѧ\n"); + scanf("%d",&id); + while(!feof(fp1)) + { + fscanf(fp1,"%d%d%s%d%d%d%d",&student[i].id,&student[i].class,&student[i].name,&student[i].time_beginhour,&student[i].time_beginminute,&student[i].time_endhour,&student[i].time_endminute); + i++; + j=i; + } + fclose(fp1); + for(i=0;i<=j;i++) + { + if(student[i].id==id) + k=i; + } + fp2=fopen("a.txt","w"); + if(k==0) + { + for(i=1;i<=j;i++) + fprintf(fp2,"%d%d%s%d%d%d%d",student[i].id,student[i].class,student[i].name,student[i].time_beginhour,student[i].time_beginminute,student[i].time_endhour,student[i].time_endminute); + } + if(k>0) + { + for(i=0;i