氺题,不多说代码如下
#include<stdio.h>
#include<string.h>
#define N 100005
int str[N];
int p[N];
int main()
{
    int n,m;

 //  freopen("e://2.txt","r",stdin);
    scanf("%d",&m);
    int i,j,l=1;
    while(l<=m)
    {
        memset(p,0,sizeof(p));
        if(l!=1)
printf("\n");
        scanf("%d",&n);
        for(i=0;i<n;i++)
            scanf("%d",str+i);
         for(i=1;i<n;i++)
             if(str[i-1]>=0)
                 str[i]+=str[i-1];
             else 
             {
                 for(j=i;j<n;j++)
                     p[j]=i;
             }
             int max[3]={-9999999,0,0};
         for(i=0;i<n;i++)
         if(max[0]<str[i]) 
         { 
             max[0]=str[i];
             max[1]=p[i];
             max[2]=i;
         }
    
       printf("Case %d:\n",l);
       printf("%d %d %d\n",max[0],max[1]+1,max[2]+1);
      
         l++;
    }
    return 0;
}

相关文章:

  • 2021-09-08
  • 2021-07-05
  • 2021-09-01
  • 2022-02-01
  • 2021-09-24
猜你喜欢
  • 2022-03-07
  • 2021-08-23
  • 2021-07-12
  • 2018-07-29
  • 2022-01-20
  • 2021-08-27
相关资源
相似解决方案