首页 > 学院 > 开发设计 > 正文

HDU-1003

2019-11-08 03:02:08
字体:
来源:转载
供稿:网友

http://acm.hdu.edu.cn/showPRoblem.php?pid=1003

#include <iostream>#include <stdio.h>#include<algorithm>#include <string.h>using namespace std;int main(){    int T;    cin>>T;    int CASE=1;    while(T--){        int n;        cin>>n;        int i,j;        int sum=0;        int ans=-10000;        int temp=0;        int  pos1=0,pos2=0;        for(i=0;i<n;i++){            int t;            scanf("%d",&t);            sum+=t;             if(sum>ans){                ans=sum;                pos1=temp;                pos2=i;            }            if(sum<0){                sum=0;                temp=i+1;            }        }        cout<<"Case "<<CASE++<<":"<<endl;       // cout<<ans<<" "<<pos1+1<<" "<<pos2+1<<endl;        printf("%d %d %d/n",ans,pos1+1,pos2+1);        if(T>0)cout<<endl;    }    return 0;}


上一篇:可见性

下一篇:类型转换

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表