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.
64 lines
1.2 KiB
64 lines
1.2 KiB
1 year ago
|
#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;
|
||
|
};
|
||
|
|
||
|
struct stu_info stu[N]={{"10001",11,0,"Zhang",99.5,88.5,89.5},
|
||
|
{"10002",12,0,"Yang",77.9,56.5,87.5},
|
||
|
{"10003",11,0,"Liang",92.5,99.0,60.5}};
|
||
|
|
||
|
void sort(struct stu_info *stu,int n)
|
||
|
{
|
||
|
int i,j;
|
||
|
struct stu_info tmp;
|
||
|
for(i=0;i<n;i++)
|
||
|
{
|
||
|
for(j=0;j<n-i-1;j++)
|
||
|
{
|
||
|
if(((stu+j)->cls>(stu+j+1)->cls)||((stu+j)->cls==(stu+j+1)->cls)&&((stu+j)->num>(stu+j+1)->num))
|
||
|
{
|
||
|
tmp = *(stu+j);
|
||
|
*(stu+j) = *(stu+j+1);
|
||
|
*(stu+j+1) = tmp;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
struct stu_info mod;
|
||
|
scanf("%s",&mod.num);
|
||
|
scanf("%d",&mod.cls);
|
||
|
scanf("%s",&mod.name);
|
||
|
scanf("%f",&mod.math);
|
||
|
scanf("%f",&mod.physics);
|
||
|
scanf("%f",&mod.english);
|
||
|
int i;
|
||
|
for(i=0;i<N;i++)
|
||
|
{
|
||
|
if(strcmp(stu[i].num,mod.num)==0)
|
||
|
{
|
||
|
*(stu+i)=mod;
|
||
|
}
|
||
|
}
|
||
|
sort(stu,N);
|
||
|
for(i=0;i<N;i++)
|
||
|
{
|
||
|
if(i==0||stu[i].cls!=stu[i-1].cls) printf("%2d ",stu[i].cls);
|
||
|
else printf(" ");
|
||
|
printf("%s %s %.1f %.1f %.1f",stu[i].num,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
||
|
if(stu[i].flag) printf(" modified");
|
||
|
printf("\n");
|
||
|
}
|
||
|
return 0;
|
||
|
}
|