View Code of Problem 100

#include<stdio.h>
#include<string.h>

struct music
{
	char name[50];
	int m,s;
	int score;
}num[105];

int main()
{
	int n, t;
	char s[50];
	int x, y;
	scanf("%d", &n);
	while(n != 0)
	{
		for(int i = 0; i < n; i++)
		{
			scanf("%s", num[i].name);
			scanf("%d:%d", &num[i].m, &num[i].s);
			num[i].s += 60 * num[i].m;
			num[i].score = 0;
		}
		scanf("%d", &t);
		while(t--)
		{
			scanf("%s", s);
			scanf("%d:%d", &x, &y);
			y += x * 60;
			for(int i = 0; i < n ;i++)
				if(strcmp(s, num[i].name) == 0)
					num[i].score += 5.0 * y / num[i].s;
		}
		for(int i = 0; i < n ; i++)
		{
			int pos = 0;
			for(int j = 1; j < n; j++)
			{
				if(num[j].score > num[pos].score)
					pos = j;
				else if(num[j].score == num[pos].score)
					if(strcmp(num[j].name, num[pos].name) < 0)
						pos = j;
			}
			printf("%s %d\n", num[pos].name, num[pos].score);
			num[pos].score = -1;
		}
		scanf("%d", &n);
	}
	
	return 0;
 } 

Double click to view unformatted code.


Back to problem 100