反正无聊,传一个一学期下来,自认为最有感觉,在我所有作业中编的最好,最快,也最喜欢(喜欢的理由是:编的最好最快)的程序(可能比较简单吧):(颜色弄了我好久)
/* A Contesting Decision*/
#include
#include
#include
#include
#include
#include
int compare_2(int time[100],int a); /*比较解决问题多少的函数原型*/
int compare_1(int result[100],int a,int time[100]);/*比较分数高低的函数原型*/
int compare_1(int result[100],int a,int time[100]);/*比较分数高低的函数原型*/
struct team
{
int problem; /*problem为解决问题的数量*/
int mark; /*mark为分数*/
int sub_time[8]; /*sub_time为每题的sub和time*/
char team_name[20]; /*team_name为队名*/
};
int main()
{
int time[100]; /*time为时间*/
int result[100]; /*result为分数*/
int number; /*number为解决问题的数量*/
int s=0,i,j; /*s,i,j都为计数*/
struct team b;
char name[100][20]; /*name为队名*/
{
int time[100]; /*time为时间*/
int result[100]; /*result为分数*/
int number; /*number为解决问题的数量*/
int s=0,i,j; /*s,i,j都为计数*/
struct team b;
char name[100][20]; /*name为队名*/
scanf("%d",&number);
while (s<number)
{
b.problem=4; /*假设开始每队都做出4题*/
while (s<number)
{
b.problem=4; /*假设开始每队都做出4题*/
scanf("%s",b.team_name);/*输入队名*/
for (i=0;i<8;i++)
scanf("%d",&b.sub_time[i]); /*输入每题的sub和time*/
scanf("%d",&b.sub_time[i]); /*输入每题的sub和time*/
b.mark=0;
for (j=0;j<=6;j+=2)
{
if (b.sub_time[j+1]==0) /*如果有一题时间为0*/
{
b.problem--; /*解决的问题数量减1*/
b.sub_time[j]=1;
}
b.mark+=b.sub_time[j+1]+(b.sub_time[j]-1)*20; /*计算分数*/
}
{
if (b.sub_time[j+1]==0) /*如果有一题时间为0*/
{
b.problem--; /*解决的问题数量减1*/
b.sub_time[j]=1;
}
b.mark+=b.sub_time[j+1]+(b.sub_time[j]-1)*20; /*计算分数*/
}
strcpy(name[s],b.team_name);
time[s]=b.problem;
result[s]=b.mark;
s++;
}
time[s]=b.problem;
result[s]=b.mark;
s++;
}
printf("%s %d %d\n",name[compare_1(result,s,time)],time[compare_1(result,s,time)],result[compare_1(result,s,time)]);/*输出队名,做出题的数量和分数*/
return 0;
}
}
int compare_2(int time[100],int a) /*比较解决问题多少的函数*/
{
int b,c;
{
int b,c;
c=time[0];
for (b=1;b<a;b++)
{
if (c>time[b])
{
c=c;
}
else
{
c=time[b];
}
}
return c;
}
{
if (c>time[b])
{
c=c;
}
else
{
c=time[b];
}
}
return c;
}
int compare_1(int result[100],int a,int time[100]) /*比较分数高低的函数*/
{
int b,c,d=0;
{
int b,c,d=0;
c=result[0];
for (b=0;b<a;b++)
{
if (time[b]==compare_2(time,a))
{
if (c<result[b])
{
c=c;
}
else
{
c=result[b];
d=b;
}
}
}
return d;
}
{
if (time[b]==compare_2(time,a))
{
if (c<result[b])
{
c=c;
}
else
{
c=result[b];
d=b;
}
}
}
return d;
}

没有评论:
发表评论