题目:http://acm.hdu.edu.cn/showproblem.php?pid=1003
#include <iostream> using namespace std; int b,e,n; int max_num() { int res_max = -(1<<30); int suffeix_max = 0; int tb ; tb = b = e = 0; for(int j=0; j<n; j++) { int t; cin>>t; suffeix_max = suffeix_max + t; if(suffeix_max>res_max) { res_max = suffeix_max; b = tb; e = j; } if(suffeix_max<0) { suffeix_max = 0; tb = j+1; } } return res_max; } int main() { int T; cin>>T; for(int i=0; i<T; i++) { cin>>n; int r = max_num(); cout<<"Case "<<i+1<<":"<<endl; cout<<r<<" "<<b+1<<" "<<e+1<<endl; if(i!=T-1) cout<<endl; } return 0; }