bool second(int i, int j) { return (find_prod(i)<find_prod(j)); }
...which is using find_prod() defined by me.
It seems It's working fine. But how do I modify it so that when find_prod(i)==find_prod(j) the first number will be the smaller (i or j without find_prod() function)? Shall I use tie? If so, how?
bool second( int i, int j )
{
bool result;
result = find_prod(i) < find_prod(j);
return result;
}
And you want to change it so that the result of the computation on line 4 will be:
true, IF find_prod(i) < find_prod(j)
false, IF find_prod(i) > find_prod(j)
true, IF find_prod(i) == find_prod(j) AND i < j
false, IF find_prod(i) == find_prod(j) AND !(i < j)
How about some ifelse?
Note, your functions imply that the find_prod accesses some global variable. The use of global variables is almost always a bad design.