ADD file via upload

main
p9r5svm3g 1 year ago
parent 570cf80f50
commit 19ad71cb99

@ -0,0 +1,61 @@
#include<stdio.h>
#include<string.h>
struct stu
{
char num[20];
int c,x;
char name[20];
float m,p,e;
};
struct stu stu[3]={{"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 min(struct stu *stu,int n)
{
int i,j;
struct stu t;
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(((stu+j)->c>(stu+j+1)->c)||((stu+j)->c==(stu+j+1)->c)&&((stu+j)->num>(stu+j+1)->num))
{
t = *(stu+j);
*(stu+j) = *(stu+j+1);
*(stu+j+1) = t;
}
}
}
return;
}
int main()
{
struct stu g;
scanf("%s",&g.num);
scanf("%d",&g.c);
scanf("%s",&g.name);
scanf("%f",&g.m);
scanf("%f",&g.p);
scanf("%f",&g.e);
int i;
for(i=0;i<3;i++)
{
if(strcmp(stu[i].num,g.num)==0)
{
*(stu+i)=g;
}
}
min(stu,3);
for(i=0;i<3;i++)
{
if(i==0||stu[i].c!=stu[i-1].c) printf("%2d ",stu[i].c);
else printf(" ");
printf("%s %s %.1f %.1f %.1f",stu[i].num,stu[i].name,stu[i].m,stu[i].p,stu[i].e);
if(stu[i].x) printf(" modified");
printf("\n");
}
return 0;
}
Loading…
Cancel
Save