ADD file via upload

main
pax8rtyjc 1 year ago
parent b6d76cc0a3
commit 8d68628273

@ -0,0 +1,108 @@
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
void delete1();
void order();
void output();
int sum=2;
struct stu
{
int Id;
int clas;
char name[100];
float score1;
float score2;
float score3;
float score;
}stu[100]={{10001,11,"Zhang",99.5,88.5,89.5,277.5},
{10002,12,"Yang",77.9,56.5,87.5,221.9},
{10003,11,"Liang",92.5,99.0,60.5,252}};
int main()
{
while(1)
{
order();
output();
delete1();
}
}
void delete1()
{
char b[100];
scanf("%s",&b);
int c=-56356,f=1,len1,len=strlen(b);
if(b[0]>'0'&&b[0]<'9')
{
c=0;
for(int k=0;k<len;k++)
{
c=c*10+b[k]-'0';
}
}
printf("Are you sure(yes/no)?\n");
char a,t;
t=getchar();
a=getchar();
if(a=='y')
{
for(int i=0;i<=sum;i++)
{
f=1;
len1=strlen((stu[i].name));
for(int x=0;x<len1;x++)
{
if(stu[i].name[x]!=b[x])
{
f=0;
}
}
if(stu[i].Id==c||f)
{
for(int j=i;j<=sum;j++)
{
stu[j]=stu[j+1];
}
sum=sum-1;
}
}
}
else if(a=='n')
{
output();
exit(0);
}
output();
exit(0);
}
void order()
{
for(int i=0;i<=sum;i++)
{
for(int j=i;j<=sum;j++)
{
if(stu[i].clas>stu[j].clas)
{
stu[sum+1]=stu[i];
stu[i]=stu[j];
stu[j]=stu[sum+1];
}
else if(stu[i].clas==stu[j].clas)
{
if(stu[i].score<stu[j].score)
{
stu[sum+1]=stu[i];
stu[i]=stu[j];
stu[j]=stu[sum+1];
}
}
}
}
}
void output()
{
for(int i=0;i<=sum;i++)
{
printf("%d %d %s %.1f %.1f %.1f \n",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3);
}
}
Loading…
Cancel
Save