C++ Swap help me?

int mainFinder(int 0, int 5){
if (l == r){
for(int i = 0; i < 6; i++){
res[i] = 0;
op[i] = ' ';
}

int res = finder(0, 0, 0);
if(res != -1)
return 1;
}
else
{
for(int i = l; i <= r; i++){
std::swap(arr[l], arr[i]);
int res = mainFinder(l+1, r);
std::swap(arr[l], arr[i]);
if(res == 1)
return 1;
}
}
return -1;

}
code output :(
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Line 1: That's not how to declare arguments.

You have many undefined variables.

Line 4: res is an array. L8: res is redeclared as a simple int. You can't do that in the same scope.

Line 8: finder is undefined.

Line 15,17: You need the <utility> header in order to use std::swap. l is undefined.
(<algorithm> header if you're using C++98.)





Topic archived. No new replies allowed.