View Code of Problem 61

#include <stdio.h>

void Max(int p[],int n){
	int i,temp,j,max=1;
	for (i=0;i<n;i++){
		for (j=i;j<n;j++){
			if (p[i]<p[j]){
				temp=p[i];
				p[i]=p[j];
				p[j]=temp;
			}
		}
	}
	for (i=0;i<n;i++){
		if (max< p[i]*(i+1))
			max=p[i]*(i+1);
	}
	printf("%d\n",max);
}

int main(int argc, char* argv[])
{
	int n,t[100];
	int a[100][100];
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d",&t[i]);
		for (int j=0;j<t[i];j++)
			scanf("%d",&a[i][j]);
	}
	for(i=0;i<n;i++)
		Max(a[i],t[i]);
	return 0;
}
/*
Main.c: In function 'main':
Main.c:31:6: error: 'i' undeclared (first use in this function)
  for(i=0;i<n;i++)
      ^
Main.c:31:6: note: each undeclared identifier is reported only once for each function it appears in
*/

Double click to view unformatted code.


Back to problem 61