#include
using namespace std;
Const int N=6;
Int * findMissing (int arr [], int n, int& ResArrSize);
Arr void printArray (int * and an int arrSize);
Int main () {
Int arr [N]={3, 1, 3, 0, 6, 4};
Int resArrSize;
Int * missingArr=NULL;
MissingArr=findMissing (arr, N, resArrSize);
cout <"The logical size of The new array is" & lt;
The delete [] missingArr;
MissingArr=NULL;
return 0;
}
Int * findMissing (int arr [], int n, int& ResArrSize) {
int i, j;
Int missingArrSize;
Int * range=new int [n + 1);
for (i=0; i <(n + 1); I++) {
Range [I]=I;
}
MissingArrSize=n + 1;
for (i=0; i <(n + 1); I++) {
If (range [arr [I]].=1) {
Range [arr [I]]=1;
MissingArrSize -;
}
}
J=0;
Int * missingArr=new int [missingArrSize];
for (i=0; i <(n + 1); I++) {
If (range [I]!=1) {
MissingArr [j]=range [I];
J++;
}
}
The delete [] range;
The range=NULL;
ResArrSize=missingArrSize;
Return missingArr;
}
Arr void printArray (int * and an int arrSize) {
int i;
for (i=0; i
Thank you very much!!!!!
CodePudding user response:
Crossing the lineIf (range [arr [I]].=1) {//this sentence, because I up to 6, the arr is the most effective element six, so arr [6] is invalid element, so the cross-border
CodePudding user response:
Wow, that's it! Thank you very much.