`
wangqisen
  • 浏览: 47268 次
文章分类
社区版块
存档分类
最新评论

7.1.2

 
阅读更多
#include <iostream>
using namespace std;
#define MAXN 20
long start=1,end=1,n,s[MAXN];
int f1,f2;
long max;
void input();
void getMax();
int main(){
	while(true){
	input();
	getMax();
	cout<<max<<endl;
	}
}
void getMax(){
	start=1,end=1;
	int i=start;
	long temp=1;
	max=0;
	for(;start<=n;start++){
		for(end=start;end<=n;end++){
			int k=start;
			temp=1;
			while(k<=end){
			temp=s[k]*temp;
			k++;
			}
			if(temp>max){
				max=temp;
				f1=start;
				f2=end;
			}
		}
	}
}
void input(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>s[i];
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics