选出了不连续的元素之和
一开始思路错误了,这样编写程序只能选出不连续的子列和,但题目一般是要求连续的
//the maximum of subsequences
//Divide-and-Conquer
#include<stdio.h>
#include<stdlib.h>
int* GeneArray(int n);
int MaxSubSeq(int* a, int n);
int Sort(int*a, int left, int right);
int Merge(int max1, int max2);
int main()
{
int n; //the size of the array
int maxsum;//the maximum of the submatrix
printf("Please input the size of the array to be sorted : ");
scanf("%d",&n);
int* array = GeneArray(n);
int i;
for(i = 0; i < n; i++)
{
printf("%d ", array[i]);
}
maxsum = MaxSubSeq(array, n);
printf("\nthe maximum of subsequence is %d", maxsum);
return 0;
}
int MaxSubSeq(int*a, int n)
{
int max;
max = Sort