problem in pushback array element in vector array

Pages: 12
Maybe you should get the value from aValues instead of array (line 7.)
Last edited on
k well when put the above code in function like this

1
2
3
4
5
6
7
8
9
10
11
12
13
int trace( std::vector<int>  array )
{
	int mn = 0;
	mn = array[0];
	for(int j = 0; j < array.size() ; j++)
    {
		if (array[j] < mn) 
		{
			mn = array[j];
		}
    }
	return mn;
}



and called like this
int mn = trace(aValues)
and it work fine returned me 2.

I did not get that why it gave me wrong minimum values by putting it inside main function .


Last edited on
In the main function you used aValues and array. In the function you only use the vector.
Topic archived. No new replies allowed.
Pages: 12