The main () {
Int MaxSubSequenceSum (int A [], int N);
Int M=8, a;
Int B [8];
for(int i=0; i
}
A=MaxSubSequenceSum (B [8], M);
Printf (" % d ", a);
}
Int MaxSubSequenceSum (int A [], int N) {
Int ThisSum MaxSum, I, j;
MaxSum=0;
for(i=0; i
ThisSum=0;
For (j=1; J
ThisSum +=A, [j].
If (ThisSum> MaxSum)
MaxSum=ThisSum;
}
}
Return MaxSum;
}
Error:
September 25 C: \ Users \ \ Desktop \ \ C 92906 unnamed 1. CPP [Error] invalid conversion from 'int' to 'int * [- fpermissive]
3 6 C: \ \ Users \ \ Desktop \ 92906 C unnamed 1. CPP/Error initializing argument 1 of 'int MaxSubSequenceSum (int x, int)' [- fpermissive]
CodePudding user response:
A=MaxSubSequenceSum (B [8] , M); Remove the redCodePudding user response:
Thank you, the program can run, the mistake is what meaning, can you explain itCodePudding user response:
Invalid conversion from 'int' to 'int * [- fpermissive]Invalid transformation: from int to int *
B [8] member is an array, is of type int,
Parameter int A [], A is an array, the equivalent of int * A, is type int * and so argument must be A pointer or an array (array name do parameter degradation for A pointer, is the first address of the array)
CodePudding user response:
Parameter to int * type, and arguments of type int, so it is invalid,