From 12dd163db7c35d2bdf7abda4cc746fa6a25af4d5 Mon Sep 17 00:00:00 2001 From: p72fupixj Date: Sun, 5 Nov 2023 15:19:18 +0800 Subject: [PATCH] ADD file via upload --- 5.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 5.c diff --git a/5.c b/5.c new file mode 100644 index 0000000..16067a5 --- /dev/null +++ b/5.c @@ -0,0 +1,65 @@ +#include +#include +#define N 3 + +struct stu_info +{ + char num[20]; + int cls,flag; + char name[20]; + float math,physics,english,total; +}; + +struct stu_info stu[N]={{"10001",11,1,"Zhang",99.5,88.5,89.5}, + {"10002",12,1,"Yang",77.9,56.5,87.5}, + {"10003",11,1,"Liang",92.5,99.0,60.5}}; + + +void del(struct stu_info* stu,const char* key) +{ + int i,exist=0; + for (i=0;inum,key)==0||strcmp((stu+i)->name,key)==0) + { + (stu+i)->flag=0; + exist=1; + } + } + for(i=0;iflag) printf("%s %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english); + if(exist) + { + char yn; + printf("Are you sure(yes/no)?\n"); + scanf(" %c",&yn); + if(yn=='y') + { + int st=0; + for(i=0;iflag||st==1) + { + st=1; + *(stu+i)=*(stu+i+1); + } + } + return; + } + else if(yn=='n') + { + for(i=0;i