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.

182 lines
4.7 KiB

6 years ago
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#define N 3
#define M 10
int add = N - 1;
int sum[N] = { 0 }, Max[N], Min[N];
float aver[N] = { 0 };
struct player
{
int num;
char name[8];
int score[M];
};
void c(const unsigned short textColor)
{
if(textColor>=0 && textColor<=15)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), textColor);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);}
void Inistplayer(struct player a[], int n)
{
int i;
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>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
for (i = 0; i < n; i++)
scanf("%d %s", &a[i].num, a[i].name);
}
void Inputscore(int score[], int n)
{
int i;
for (i = 0; i < n; i++)
scanf("%d",&score[i]);
}
void sort(struct player a[], float b[], int n)
{
int i, k, j,t;
float temp;
char str[8];
for (i = 0; i < n-1; i++)
{
k = i;
for (j = i + 1; j < n; j++)
if (b[k] > b[j])
k = j;
if (k != i)
{
temp = b[i];
b[i] = b[k];
b[k] = temp;
strcpy(str, a[i].name);
strcpy(a[i].name, a[k].name);
strcpy(a[k].name, str);
t = a[i].num;
a[i].num = a[k].num;
a[k].num = t;
}
}
}
int main()
{
int flag = 1, i, m, j;
char n;
FILE *fp;
struct player a[20];
while(flag)
{
c(4);printf(" <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ \n");
c(4);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><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");
c(1);printf(" 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \n");
c(5);printf(" 2<><32><EFBFBD><EFBFBD>ί<EFBFBD><CEAF><EFBFBD><EFBFBD> \n");
c(6);printf(" 3<><33><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD> \n");
c(8);printf(" 4<><34><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD>ѯ \n");
c(9);printf(" 5<><35>׷<EFBFBD><D7B7>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \n");
c(10);printf(" 6<><36>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> \n");
c(13);printf(" 7<><37><EFBFBD>˳<EFBFBD>ϵͳ \n");
c(4);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><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");
c(15);printf(" \n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>");
scanf("%d,",&n);
switch(n)
{
case 1:system("cls");
Inistplayer(a,N);printf("Press any key to continue...");
getch();system("cls");
break;
case 2:
system("cls");
for(i=0;i<N;i++)
{
printf("ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>гɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ10<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>Ϊ0\n");
printf("<EFBFBD><EFBFBD>ί<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%dλѡ<CEBB>ֵķ<D6B5><C4B7><EFBFBD><EFBFBD>ǣ<EFBFBD>",i+1);
Inputscore(a[i].score,M);
printf("<EFBFBD><EFBFBD>%dλ<64><CEBB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>гɼ<D0B3><C9BC><EFBFBD>\n",i+1);
for(j=0;j<M;j++)
{ printf("%d\t",a[i].score[j]);}
printf("\n") ;
printf("Press any key to continue...");
getch();
system("cls");
}
system("cls");
break;
case 3:
system("cls");
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");
for(i=0;i<N;i++)
{
Max[i]=a[i].score[0];
Min[i]=a[i].score[0];
for(j=0;j<M;j++)
{
sum[i]+=a[i].score[j];
if(Max[i]<a[i].score[j])
Max[i]=a[i].score[j];
if(Min[i]>a[i].score[j])
Min[i]=a[i].score[j];
}
aver[i]=(float)(sum[i]-Max[i]-Min[i])/(M-2);
}
sort(a,aver,N);
for(i=0;i<N;i++)
{
printf("%s\t%5.2f\n",a[i].name,aver[i]);}printf("Press any key to continue...");
getch();
system("cls"); break;
case 4:
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ѯѡ<EFBFBD>֣<EFBFBD>");
scanf("%d",&m);
for(i=0;i<N;i++)
if(a[i].num==m)
{
printf("<EFBFBD><EFBFBD>%d<><64>ѡ<EFBFBD><D1A1>%s <20>ܷ<EFBFBD>:%d,<2C><><EFBFBD>߷<EFBFBD>%d,<2C><><EFBFBD>ͷ<EFBFBD>%d,ƽ<><C6BD><EFBFBD><EFBFBD>%5.2f",a[i].num,a[i].name,sum[i],Max[i],Min[i],aver[i]);
printf("\n");
}printf("Press any key to continue...");
getch();
system("cls"); break;
case 5:
system("cls"); printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ׷<EFBFBD>ӵ<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
add=add+1;
scanf("%d %s",&a[add].num,a[add].name);
printf("Press any key to continue...");
getch();
system("cls"); break;
case 6:
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>\n");
fp=fopen("<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>.txt","w");
int i=0;
for(i<add+2;i++;)
{
fprintf(fp,"%d %s %d %d %d %5.2f",a[i].num,a[i].name,sum[i],Max[i],Min[i],aver[i]);
}
fclose(fp);printf("Press any key to continue...");
getch();
system("cls"); break;
case 7:system("cls");exit(0);
system("cls"); break;
default:flag=0;
}
}
return 0;
}