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.
singer/歌手比赛系统最终版 (2).cpp

214 lines
4.1 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100 /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100<30><30>*/
#define M 10 /*<2A><>ί<EFBFBD><CEAF><EFBFBD><EFBFBD>10<31><30>*/
struct player
{
int num; /*<2A><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>*/
char name[100]; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
int score[10]; /*<2A><>ί<EFBFBD><CEAF><EFBFBD>ֳɼ<D6B3>*/
float ave; /*<2A><><EFBFBD>ֵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>*/
int index; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
}singer[N];
void f1(struct player singer[],int n) /*f1<66><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>*/
{
int i;
for(i=0;i<n;i++)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ(<28><><EFBFBD>ֱ<EFBFBD><D6B1>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ÿո<C3BF><D5B8><EFBFBD><EFBFBD><EFBFBD>): ",i+1);
scanf("%d%s",&singer[i].num,&singer[i].name);
}
printf("\n\n");
}
void f2(int score[],int n) /*f2<66><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD><CEAF><EFBFBD>ֵĺ<D6B5><C4BA><EFBFBD>*/
{
int i;
for(i=0;i<M;i++)
{
loop: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%dλ<64><CEBB>ί<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>(1-10): ",i+1);
scanf("%d",&score[i]);
if(score[i]<0||score[i]>10)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
goto loop;
}
}
printf("\n\n");
}
int main(void)
{
int n,i,j,c,sum=0;
system("color f9"); /*<2A>ı<C4B1><E4B4B0><EFBFBD><EFBFBD>ɫ*/
printf("* * * * * * * * * * * * * * * * <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ϵͳ * * * * * * * * * * * * * * * * \n");
printf("\n");
printf(" 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \n");
printf(" 2 <20><>ί<EFBFBD><CEAF><EFBFBD><EFBFBD> \n ");
printf(" 3 <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD> \n");
printf(" 4 <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD> \n");
printf(" 5 <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ \n");
printf(" 6 ׷<>Ӹ<EFBFBD><D3B8><EFBFBD> \n");
printf(" 7 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD> \n");
printf(" 8 <20>˳<EFBFBD>ϵͳ \n");
do
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ž<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&n);
switch(n)
{
case 1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>): ");
scanf("%d",&c);
if(c>0&&c<=100)
f1(singer,c);
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ž<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD>\n");
break;
case 2:
for(i=0;i<c;i++)
{
printf("<EFBFBD><EFBFBD>%dλ<64><CEBB><EFBFBD>ֵijɼ<C4B3><C9BC><EFBFBD><EFBFBD><EFBFBD>:",i+1);
printf("\n");
f2(singer[i].score,M);
}
break;
case 3:
{
float Max[c],Min[c],sum[c];
for(i=0;i<c;i++) /*ͨ<><CDA8>˫ѭ<CBAB><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ֵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>*/
{
Max[i]=singer[i].score[0]; /*<2A><><EFBFBD><EFBFBD><69><CEBB><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ίһ<CEAF><D2BB><EFBFBD>ijɼ<C4B3>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ֵ*/
Min[i]=singer[i].score[0];
sum[i]=0;
for(j=0;j<M;j++)
{
sum[i]=sum[i]+singer[i].score[j];
if(Max[i]<singer[i].score[j])
Max[i]=singer[i].score[j];
if(Min[i]>singer[i].score[j])
Min[i]=singer[i].score[j];
}
singer[i].ave=(sum[i]-Max[i]-Min[i])/(M-2);
}
for(i=0;i<c;i++)
{
printf("<EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ: ",i+1);
printf("<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>Ϊ:%d <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:%s <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>:%.2f",singer[i].num,singer[i].name,singer[i].ave);
printf("\n");
}
printf("\n\n");
break;
}
case 4:
int i,j,k;
struct player temp;
for(i=0;i<c-1;i++) /*ʹ<><CAB9>ð<EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
{
k=i;
for(j=i+1;j<c;j++)
if(singer[j].ave>singer[k].ave)
k=j;
temp=singer[k];
singer[k]=singer[i];
singer[i]=temp;
}
printf("<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹߵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n\n ");
for(i=0;i<c;i++)
{
singer[i].index=i+1;
printf("<EFBFBD><EFBFBD>%d<><64><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>Ϣ:\n",i+1);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:%d <20><><EFBFBD><EFBFBD>Ϊ:%d <20><><EFBFBD><EFBFBD>Ϊ:%s ƽ<><C6BD><EFBFBD>ֳɼ<D6B3>Ϊ:%.2f",singer[i].index,singer[i].num,singer[i].name,singer[i].ave);
printf("\n");
}
printf("\n\n");
break;
case 5:
int m;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>ĸ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&m);
for(i=0;i<c;i++)
if(singer[i].num==m)
{
printf("<EFBFBD>ø<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d <20>ø<EFBFBD><C3B8>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>:%s <20>ø<EFBFBD><C3B8>ֵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>:%.2f",singer[i].index,singer[i].name,singer[i].ave);
printf("\n");
}
printf("\n");
break;
case 6:
{
int add=c,s,d;
printf("׷<EFBFBD>Ӹ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&s);
d=add+s;
for(add;add<d;add++)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ׷<EFBFBD>ӵĸ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d%s",&singer[add].num,&singer[add].name);
}
printf("\n");
}
break;
case 7:
FILE *fp;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>:\n");
fp=fopen("D:\\singer.txt","w");
for(int i=0;i<c;i++)
{
fprintf(fp,"%d%d%s%f\n",singer[i].index,singer[i].num,singer[i].name,singer[i].ave);
}
fclose(fp);
break;
case 8:
exit(0);
break;
default:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n\n");
main();
return 0;
}
}while(n!=0);
return 0;
}