|
|
|
|
@ -209,67 +209,68 @@ int main() {
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#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)
|
|
|
|
|
char num[20];
|
|
|
|
|
int cls,flag;
|
|
|
|
|
char name[20];
|
|
|
|
|
float math,physics,english,total;
|
|
|
|
|
}stu[N]={"10001",11,1,"Zhang",99.5,88.5,89.5,0,"10002",12,1,"Yang",77.9,56.5,87.5,0,"10003",11,1,"Liang",92.5,99.0,60.5,0};
|
|
|
|
|
void del(struct stu_info stu[],const char key[])
|
|
|
|
|
{
|
|
|
|
|
int i,exist=0;
|
|
|
|
|
for (i=0;i<N;i++)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp((stu+i)->num,key)==0||strcmp((stu+i)->name,key)==0)
|
|
|
|
|
{
|
|
|
|
|
(stu+i)->flag=0;
|
|
|
|
|
exist=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<N;i++) if((stu+i)->flag) 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[表情])?\n");
|
|
|
|
|
scanf(" %c",&yn);
|
|
|
|
|
if(yn=='y')
|
|
|
|
|
{
|
|
|
|
|
int st=0;
|
|
|
|
|
for(i=0;i<N-1;i++)
|
|
|
|
|
{
|
|
|
|
|
if(!(stu+i)->flag||st==1)
|
|
|
|
|
{
|
|
|
|
|
st=1;
|
|
|
|
|
*(stu+i)=*(stu+i+1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if(yn=='n')
|
|
|
|
|
{
|
|
|
|
|
for(i=0;i<N;i++)
|
|
|
|
|
{
|
|
|
|
|
stu[i].flag=1;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int i,exist=0,j;
|
|
|
|
|
struct stu_info t;
|
|
|
|
|
for(i=0;i<N;i++)
|
|
|
|
|
stu[i].total=stu[i].math+stu[i].physics+stu[i].english;
|
|
|
|
|
for(i=0;i<(N-1);i++){
|
|
|
|
|
for(j=i+1;j<N;j++){
|
|
|
|
|
if(stu[j].total>=stu[i].total)
|
|
|
|
|
{t=stu[i];
|
|
|
|
|
stu[i]=stu[j];
|
|
|
|
|
stu[j]=t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i=0;i<N;i++)
|
|
|
|
|
{
|
|
|
|
|
if((strcmp((stu+i)->num,key)==0)||(strcmp((stu+i)->name,key)==0))
|
|
|
|
|
{
|
|
|
|
|
stu[i].flag=0;
|
|
|
|
|
exist=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int a;
|
|
|
|
|
if(exist){
|
|
|
|
|
for(a=11;a<=12;a++){
|
|
|
|
|
for(i=0;i<N;i++){
|
|
|
|
|
if(stu[i].flag&&stu[i].cls==a)
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(!exist){
|
|
|
|
|
for(i=0;i<N;i++)
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Are you sure(yes[表情])?\n");
|
|
|
|
|
char ch2;
|
|
|
|
|
scanf("%c",&ch2);
|
|
|
|
|
if(ch2=='y'){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if(ch2=='n'){
|
|
|
|
|
for(i=0;i<N;i++)
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
char key[20];
|
|
|
|
|
scanf("%s",key);
|
|
|
|
|
del(stu,key);
|
|
|
|
|
return 0;
|
|
|
|
|
gets(key);
|
|
|
|
|
del(stu,key);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
第6步骤
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
|