PAT 01-1

时间:2022-03-06 05:38:47
#include <stdio.h>

int main()
{
int i;
int k;
int a[];
scanf("%d", &k);
for(i = ; i < k; i++)
{
scanf("%d", &a[i]);
}
printf("%d", MaxSubseqSum(a, k));
return ;
} int MaxSubseqSum(int a[], int n)
{
int ThisSum, MaxSum;
int i;
ThisSum = MaxSum = ;
for(i = ; i < n; i++)
{
ThisSum += a[i];
if(ThisSum > MaxSum)
MaxSum = ThisSum;
else if(ThisSum < )
ThisSum = ;
}
return MaxSum;
}