#include<stdio.h> void main() { int t; scanf_s("%d", &t); while (t--) { int n, max = 0; scanf("%d", &n); int a[10000]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i]>a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if (a[i] * (j-i+1) > max) { max = a[i] * (j - i + 1); } } } printf("%d\n", max); } } /* Main.c:2:6: warning: return type of 'main' is not 'int' [-Wmain] void main() ^~~~ Main.c: In function 'main': Main.c:5:2: warning: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration] scanf_s("%d", &t); ^~~~~~~ scanf /usr/bin/ld: /tmp/cc4vlPUn.o: in function `main': Main.c:(.text.startup+0x20): undefined reference to `scanf_s' collect2: error: ld returned 1 exit status */ |
Double click to view unformatted code.