You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Group18/学籍管理系统步骤5.c

73 lines
1.2 KiB

#include<stdio.h>
#include<string.h>
#define N 3
struct stu_info
{
char num[20];
int cls,flag;
char name[20];
float maths,physics,english,sum;
};
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,e=0;
for (i=0;i<N;i++)
{
if(strcmp((stu+i)->num,key)==0||strcmp((stu+i)->name,key)==0)
{
(stu+i)->flag=0;
e=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].maths,stu[i].physics,stu[i].english);
}
}
if(e)
{
char choose;
printf("Are you sure(yes/no)?\n");
scanf(" %c",&choose);
if(choose=='y')
{
int q=0;
for(i=0;i<N-1;i++)
{
if(!(stu+i)->flag||q==1)
{
q=1;
*(stu+i)=*(stu+i+1);
}
}
return;
}
else if(choose=='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].maths,stu[i].physics,stu[i].english);
}
}
}
}
int main()
{
char key[20];
scanf("%s",key);
del(stu,key);
return 0;
}