View Code of Problem 61

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		int a[n];
		int i,j;
		for(i=0;i<n;i++)
		{
			scanf("%d",a[i]);
		}
		for(i=0;i<;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if(a[i]<a[j])
				{
					int tmp;
					tmp=a[j];
					a[j]=a[i];
					a[i]=tmp;
				}
			}
		}
		int max=a[0];
		for(i=0;i<n;i++)
		{
			if((i+1)*a[i]>max)
				max=(i+1)*a[i];
		}
		printf("%d\n",max);
	}
}
/*
Main.c: In function 'main':
Main.c:16:12: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
    scanf("%d",a[i]);
           ~^  ~~~~
Main.c:18:13: error: expected expression before ';' token
   for(i=0;i<;i++)
             ^
*/

Double click to view unformatted code.


Back to problem 61