#include<iostream>
using namespace std;
int zuida(int n,int a[],int *sm,int *mm);
void main()
{
int m,n,i,j,sm,mm,t2;
int sum,max;
int up[100],down[100],t[100];
int a[100][100],b[100];
cout<<"输入二维数组的行"<<endl;
cin>>m;
cout<<"输入二维数组的行"<<endl;
cin>>n;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
b[j]=a[i][j];
sum=zuida(n,b,&sm,&mm);
up[i]=sma;
down[i]=mm;
t[i]=sum;
t2=t[0];
for(i=0;i+1<m;i++)
if(up[i]<=down[i+1] && down[i]>=up[i+1])
t2+=t[i+1];
for(j=up[i];j<up[i+1];j++)
if(a[i+1][j]>0) t2+=a[i+1][j]; //判别独立正数
cout<<t2<<endl;
}
int zuida(int n,int a[],int *sm,int *mm)
int b[100]={0};
int i,sum1=0,max1=0;
for(i=0;i<n;i++)
if(sum1<0)
sum1=a[i];
else
sum1=sum1+a[i];
b[i]=sum1;
max1=b[0];
if (max1<b[i])
{
max1= b[i];
*mm = i;
}
for (i = *mm;i >= 0;i--)
if (b[i] == a[i])
*sm= i;
break;
return max1;
我主要负责代码的编写,审核由张子超完成