Good evening, I can not find a problem in my code, it's a website exercise codewars ( ), for those who do not know the site, it is a site to train programming, here I am only dealing with the inversion of 3 and 7, ex: enter a array{ 1,3,4,7,13,17}
the array should exit% My problem is that I can not do 3 exit as 7, the result of this function is {1,7,4,3,17,13}
, my only problem is number 3. I do not know if my logic is wrong, or some other error. So I ask for your help
int* sortTwisted37(int* array, int arrayLength){
bool v;
for(int i=0;i<=arrayLength;i++){
if(array[i]<=10){
if(array[i]==7){
array[i]=array[i]-4;
v=true;
}else if(array[i]==3){
array[i]=array[i]+4;
v==true;
}
}else
v=false;
if(((array[i]-7)%10==0)&v==false){
array[i]=array[i]-4;
}else if(((array[i]-3)%10==0)&v==false){
array[i]=array[i]+4;
}
cout << array[i] << endl;
}
}
Sorry if something is wrong, I'm new to the site