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.
184 lines
2.6 KiB
184 lines
2.6 KiB
#include <stdio.h>
|
|
int j=0,q=-1;
|
|
char e;
|
|
struct st
|
|
{
|
|
int xh;
|
|
int bj;
|
|
char xm[10];
|
|
float gs;
|
|
float dw;
|
|
float yy;
|
|
}st[100];
|
|
void input()
|
|
{
|
|
printf("id ");
|
|
printf("class ");
|
|
printf("name ");
|
|
printf("score1 ");
|
|
printf("score2 ");
|
|
printf("score3\n");
|
|
scanf("%d %d %s %.1f %.1f %.1f",&st[j].xh,&st[j].bj,&st[j].xm,&st[j].gs,&st[j].dw,&st[j].yy);
|
|
printf("continue?\n");
|
|
scanf("%*[^\n]");
|
|
scanf("%*c");
|
|
scanf("%c",&e);
|
|
j++;
|
|
if(e=='n')
|
|
{
|
|
return;
|
|
}
|
|
else if(e=='y')
|
|
{
|
|
input();
|
|
}
|
|
}
|
|
void delete()
|
|
{
|
|
int i,f,m=5,n;
|
|
char mm,s[10];
|
|
printf("Are you sure\n");
|
|
scanf("%*[^\n]");
|
|
scanf("%*c");
|
|
scanf("%c\n",&mm);
|
|
if(mm=='n')
|
|
{
|
|
output();
|
|
}
|
|
if(mm=='y')
|
|
{
|
|
gets(s);
|
|
for(f=0;f<j;f++)
|
|
{
|
|
if(strcmp(s,st[f].xm)==0||strcmp(s,st[f].xh)==0)
|
|
{
|
|
m=f;
|
|
for(m;m<=j;m++)
|
|
{
|
|
st[m]=st[m+1];
|
|
}
|
|
j--;
|
|
}
|
|
}
|
|
output();
|
|
}
|
|
}
|
|
void select()
|
|
{
|
|
int d,l;
|
|
printf("ÊäÈëѧºÅ»ò°à¼¶");
|
|
scanf("%d",&d);
|
|
for(l=0;l<j;l++)
|
|
{
|
|
if(d==st[l].xh||d==st[l].bj)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",st[l].xh,st[l].bj,st[l].xm,st[l].gs,st[l].dw,st[l].yy);
|
|
}
|
|
}
|
|
}
|
|
void inorder()
|
|
{
|
|
int i;
|
|
q++;
|
|
for(i=q+1;i<j;i++)
|
|
{
|
|
if(st[q].bj>st[i].bj)
|
|
{
|
|
struct st temp;
|
|
temp=st[i];
|
|
st[i]=st[q];
|
|
st[q]=temp;
|
|
}
|
|
}
|
|
if(q==j-1)
|
|
{
|
|
q=-1;
|
|
return;
|
|
}
|
|
inorder();
|
|
}
|
|
void corder()
|
|
{
|
|
float a,b;
|
|
int i;
|
|
q++;
|
|
for(i=q+1;i<j;i++)
|
|
{
|
|
a=st[i].dw+st[i].gs+st[i].yy;
|
|
b=st[q].dw+st[q].gs+st[q].yy;
|
|
if(a>b&&st[i].bj==st[q].bj)
|
|
{
|
|
struct st temp;
|
|
temp=st[i];
|
|
st[i]=st[q];
|
|
st[q]=temp;
|
|
}
|
|
}
|
|
if(q==j)
|
|
{
|
|
q=-1;
|
|
return;
|
|
}
|
|
else corder();
|
|
}
|
|
void order()
|
|
{
|
|
inorder();
|
|
corder();
|
|
}
|
|
void output()
|
|
{
|
|
int l=0;
|
|
for(l=0;l<j;l++)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",st[l].xh,st[l].bj,st[l].xm,st[l].gs,st[l].dw,st[l].yy);
|
|
}
|
|
}
|
|
int main( )
|
|
{
|
|
int a;
|
|
mn:
|
|
printf("1.Input\n");
|
|
printf("2.delete\n");
|
|
printf("3.Select\n");
|
|
printf("4.Order\n");
|
|
printf("5.output\n");
|
|
printf("6.Quit\n");
|
|
printf("please input your option\n");
|
|
scanf("%d",&a);
|
|
switch(a)
|
|
{
|
|
case 1:
|
|
{
|
|
input();
|
|
}
|
|
break;
|
|
case 2:
|
|
{
|
|
delete();
|
|
}
|
|
break;
|
|
case 3:
|
|
{
|
|
select();
|
|
}
|
|
break;
|
|
case 4:
|
|
{
|
|
order();
|
|
}
|
|
break;
|
|
case 5:
|
|
{
|
|
output();
|
|
}
|
|
break;
|
|
case 6:
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
goto mn;
|
|
}
|
|
|