diff --git a/program 5.c b/program 5.c new file mode 100644 index 0000000..fc96efa --- /dev/null +++ b/program 5.c @@ -0,0 +1,69 @@ +#include +#include +struct stu +{ + char num[20]; + int c,x; + char name[20]; + float m,p,e,s; +}; + +struct stu stu[3]={{"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 ee(struct stu* stu,char* a[20]) +{ + int i,exist=0; + for (i=0;i<3;i++) + { + if(strcmp((stu+i)->num,a)==0||strcmp((stu+i)->name,a)==0) + { + (stu+i)->x=0; + exist=1; + } + } + if(exist) + { + + char w;scanf(" %c",&w); + if(w=='y') + { + int st=0; + for(i=0;i<2;i++) + { + if(!(stu+i)->x||st==1) + { + st=1; + *(stu+i)=*(stu+i+1); + } + } + return; + } + else if(w=='n') + { + for(i=0;i<3;i++) + { + stu[i].x=1; + printf("%s %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e); + }return; + } + } +} + +int main() +{int i; + char a[20]; + scanf("%s",a); + for (i=0;i<3;i++) + { + if(strcmp((stu+i)->num,a)==0||strcmp((stu+i)->name,a)==0) + { + (stu+i)->x=0;printf("Are you sure(yes/no)?\n"); + } + } + for(i=0;i<3;i++) if((stu+i)->x) printf("%s %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e); + ee(stu,a); + return 0; +}