View Code of Problem 61

int main()
{
    int i,j,t,n;
    int a[N];
    scanf("%d\n",&t);
    while(t--)
    {
        int max=0,sum=0;
        for(i=0;i<n;i++)
        {
            sum=a[i]*(n-i);
            if(sum>max)
              max=sum;
         }
         printf("%d\n",max);
    }
    return 0;
}
/*
Main.c: In function 'main':
Main.c:4:11: error: 'N' undeclared (first use in this function)
     int a[N];
           ^
Main.c:4:11: note: each undeclared identifier is reported only once for each function it appears in
Main.c:5:5: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
     scanf("%d\n",&t);
     ^~~~~
Main.c:5:5: warning: incompatible implicit declaration of built-in function 'scanf'
Main.c:5:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
Main.c:1:1:
+#include <stdio.h>
 int main()
Main.c:5:5:
     scanf("%d\n",&t);
     ^~~~~
Main.c:15:10: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
          printf("%d\n",max);
          ^~~~~~
Main.c:15:10: warning: incompatible implicit declaration of built-in function 'printf'
Main.c:15:10: note: include '<stdio.h>' or provide a declaration of 'printf'
Main.c:4:9: warning: unused variable 'a' [-Wunused-variable]
     int a[N];
         ^
Main.c:3:11: warning: unused variable 'j' [-Wunused-variable]
     int i,j,t,n;
           ^
*/

Double click to view unformatted code.


Back to problem 61