View Code of Problem 5

#include <stdio.h>
main()
{
	int z,i,j,p,maxa,maxb;
	int t,n,m;
	int a[10][100000];
	int b[10][100000];
	int c[10][100000];
	scanf("%d",&t);
	for (i=1;i<=t;i++)
	{
		scanf("%d%d",&a[i][0],&b[i][0]);
		for (j=1;j<=a[i][0];j++)
		{
			scanf("&d&d\n",&a[i][j],&b[i][j]);
		}
	}
	for (i=1;i<=t;i++)
	{
		maxa=a[i][1];maxb=b[i][1];
		p=1;j=1;
		for (z=1;z<=a[i][0];z++)
		{
		    while (a[i][j]!=0 && b[i][j]!=0)
		          {
			            if (a[i][j]>maxa || (a[i][j]==maxa && b[i][j]>maxb))
			            { 
				               p=j;maxa=a[i][j];maxb=b[i][j];
			            }
		          }
	       	c[i][z]=j;
	    }
	    while (c[i][j]!=0)
	    {
	    	printf("%d ",c[i][j]);
		}
		printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 5