View Code of Problem 5

#include<stdio.h>

int Whichismax(int v[],int n)
{
	int i,max;
	max = 0;
	for(i = 0;i < n;i ++)
	{
		if(v[i] > v[max])
			max = i;
	}
	return max;
}
int main(void)
{
	int i,t,n,m,a[1000][2],v[1000];
	scanf("%d",&t);
	
	while(t --)
	{
		scanf("%d %d",&n,&m);

		for( i = 0;i < n;i ++)
		{
			scanf("%d %d",&a[i][0],&a[i][1]);
		}
		for(i = 0;i < n; i ++)
			v[i] = a[i][0]*10 + a[i][1];
		for(i = 0;i < m;i ++)
		{
			printf("%d ",Whichismax(v,n) + 1);
			v[Whichismax(v,n)] = -1;
		}
	}
}

Double click to view unformatted code.


Back to problem 5