用枚举来做,记得开long long, int卡题
#include <stdio.h>
#include <string.h>
int main(void)
{
int count = 1, n;
int a[100];
while(scanf("%d", &n) != EOF){
long long int i, j;
for(i = 0; i < n; i++)
scanf("%d", &a[i]);
long long int max = 0, pro, sec, con;
for(i = 0; i < n; i++)
if(a[i] > max) max = a[i];
for(sec = 2; sec <= n; sec ++)
for(i = 0; i + sec <= n; i++){
pro = 1;
j = i;
for(con = 1;con <= sec; con++)
pro *= a[j++];
if(pro > max) max = pro;
}
printf("Case #%d: The maximum product is %lld.\n\n", count++, max);
}
return 0;
}