最小公共子序列的和

#include<stdio.h>
int MinSubsequenceSum(const int A[],int n)
{
int i,sum,MinSum;
sum=MinSum=0;
for(i=0;i<n;i++)
{
sum+=A[i];
if(sum<MinSum)
MinSum=sum;
if(sum>0)
sum=0;
}
return MinSum;
}
void main()
{
int arr[10]={3,4,-2,5,-4,6,-2,8,-9,-23};
int min=MinSubsequenceSum(arr,10);
printf("%d\n",min);
}

posted @ 2014-06-16 14:21  Jessica程序猿  阅读(287)  评论(0编辑  收藏  举报