View Code of Problem 5

#includ<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 mai(void)
{
		int i, t, n, m, a[100000][2], v[100000];
		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]*10000 + a[i][1];
			for(i = 0; i < m; i++)
			{
				if(i == m - 1)
				printf("d", Whichismax(v,n) + 1);
				else
				printf("d", Whichismax(v,n) + 1);
				v[Whichismax(v,n)] = -1;
			}
			printf("\n");
		}


	
 } 
/*
Main.c:1:2: error: invalid preprocessing directive #includ; did you mean #include?
 #includ<stdio.h>
  ^~~~~~
  include
Main.c: In function 'mai':
Main.c:18:3: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   scanf("%d", &t);
   ^~~~~
Main.c:18:3: warning: incompatible implicit declaration of built-in function 'scanf'
Main.c:18:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
Main.c:1:1:
+#include <stdio.h>
 #includ<stdio.h>
Main.c:18:3:
   scanf("%d", &t);
   ^~~~~
Main.c:32:5: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
     printf("d", Whichismax(v,n) + 1);
     ^~~~~~
Main.c:32:5: warning: incompatible implicit declaration of built-in function 'printf'
Main.c:32:5: note: include '<stdio.h>' or provide a declaration of 'printf'
Main.c:32:12: warning: too many arguments for format [-Wformat-extra-args]
     printf("d", Whichismax(v,n) + 1);
            ^~~
Main.c:34:5: warning: incompatible implicit declaration of built-in function 'printf'
     printf("d", Whichismax(v,n) + 1);
     ^~~~~~
Main.c:34:5: note: include '<stdio.h>' or provide a declaration of 'printf'
Main.c:34:12: warning: too many arguments for format [-Wformat-extra-args]
     printf("d", Whichismax(v,n) + 1);
            ^~~
Main.c:37:4: warning: incompatible implicit declaration of built-in function 'printf'
    printf("\n");
    ^~~~~~
Main.c:37:4: note: include '<stdio.h>' or provide a declaration of 'printf'
Main.c:42:2: warning: control reaches end of non-void function [-Wreturn-type]
  }
  ^
*/

Double click to view unformatted code.


Back to problem 5