/*
题目大意:
1、根据回答问题的数目,决定学生的分数;
2、回答题目数相同者,根据回答的时间的快慢,决定学生的分数;
3、回答题目数相同者,只有一个人可以获得95,85,75,65的分数,其他人只能为90,80,70,60
*/
# include <stdio.h>
struct Student /*结构体,用于存储输入的数据*/
{
int solved; /*解决问题的数目*/
int located; /*学生的位置*/
int h, m, s; /*所花费的时间*/
int consume; //所花费的总时间
int sco; /*最终的成绩*/
};
void sort(Student * stu, int num)
{
for(int i = 0; i < num; i++)//两种极端情况
{
if (stu[i].solved == 5)
{
stu[i].sco = 100;
}
if (stu[i].solved == 0)
{
stu[i].sco = 50;
}
}
int min,j,k,m,flag;
//答对4道题的
for(j = 0; j < num; j++)
{
if(stu[j].solved == 4)
{
min = stu[j].consume;
for(k = 0; k < num; k++)
{
if(stu[k].solved == 4)
{
if(min >= stu[k].consume)
{
min = stu[k].consume;
flag = stu[k].located;
//printf("----%d\n", stu[k].located);
}
}
}
break;
}
}
min = 0; //最大值清零
for(m = 0; m < num; m++)
{
if(stu[m].solved == 4)
{
if(stu[m].located == flag)
{
stu[m].sco = 95;
}else
{
stu[m].sco = 90;
}
}
}
//答对三道题的
for(j = 0; j < num; j++)
{
if(stu[j].solved == 3)
{
min = stu[j].consume;
for(k = 0; k < num; k++)
{
if(stu[k].solved == 3)
{
if(min >= stu[k].consume)
{
min = stu[k].consume;
flag = stu[k].located;
}
}
}
break;
}
}
min = 0; //最大值清零
for(m = 0; m < num; m++)
{
if(stu[m].solved == 3)
{
if(stu[m].located == flag)
{
stu[m].sco = 85;
}else
{
stu[m].sco = 80;
}
}
}
//答对二道题的
for(j = 0; j < num; j++)
{
if(stu[j].solved == 2)
{
min = stu[j].consume;
for(k = 0; k < num; k++)
{
if(stu[k].solved == 2)
{
if(min >= stu[k].consume)
{
min = stu[k].consume;
flag = stu[k].located;
}
}
}
break;
}
}
min = 0; //最大值清零
for(m = 0; m < num; m++)
{
if(stu[m].solved == 2)
{
if(stu[m].located == flag)
{
stu[m].sco = 75;
}else
{
stu[m].sco = 70;
}
}
}
//答对一道题的
for(j = 0; j < num; j++)
{
if(stu[j].solved == 1)
{
min = stu[j].consume;
for(k = 0; k < num; k++)
{
if(stu[k].solved == 1)
{
if(min >= stu[k].consume)
{
min = stu[k].consume;
flag = stu[k].located;
}
}
}
break;
}
}
min = 0; //最大值清零
for(m = 0; m < num; m++)
{
if(stu[m].solved == 1)
{
if(stu[m].located == flag)
{
stu[m].sco = 65;
}else
{
stu[m].sco = 60;
}
}
}
}
int main(void)
{
int num;
Student stu[100];
while(scanf("%d", &num) != EOF)
{
getchar(); //吸收回车符。
if(num < 0) break;
int time = 0;
for(int i = 0; i < num; i++)
{
scanf("%d %d:%d:%d", &stu[i].solved, &stu[i].h, &stu[i].m, &stu[i].s);
stu[i].located = i; /*记录下输入时的位置*/
time = (stu[i].h * 3600) + (stu[i].m * 60) + (stu[i].s);
stu[i].consume = time;
}
sort(stu, num);
for(int j = 0; j < num; j++)
{
printf("%d\n", stu[j].sco);
}
}
return 0;
}
HDU 1084 What Is Your Grade?
最新推荐文章于 2020-10-16 23:31:40 发布