### Vectors

Hello, I'm trying to write a code, for homework assignment, called increasing. What the program is supposed to do is, finding out if numbers that the users inputs are increasing or not. E.g, 1 2 3 4 are increasing, while 1 3 2 4 is not.

I'm currently getting this error, that says; Too few arguments to function 'bool increasing (std::vector<int>, int*, int'

in line 18, and it should be declared in line 6.

However, since it is declared, I don't really see the problem, and am thinking it may be lying elsewhere.

 ``1234567891011121314151617181920212223242526272829303132333435`` ``````#include #include using namespace std; bool increasing(vector arr, int numbers[], int size); int main() { int n; while (cin >> n) { vector arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } cout << (increasing(arr) ? "increasing" : "not increasing") << endl; } return 0; } bool increasing(vector arr, int numbers[], int size) { int last = numbers[0]; for(unsigned int i = 0; i < (arr.size()); ++i) { if(numbers[i] < last) { return false; } last = numbers[i]; } return true; }``````
Last edited on
All you have to do is make a copy of the vector, sort it, and use the == operator to see if they are the same.
 ``123`` ``````auto sorted = original; std::sort(std::begin(sorted), std::end(sorted)); std::cout << std::boolalpha << (sorted == original) << std::endl;``````
Last edited on
@LB: increasing. Consider repeated elements.

@OP: This is your prototype `bool increasing(vector<int> arr, int numbers[], int size);`
Count the arguments

This is your call `increasing(arr)`
count the arguments

¿don't you see anything weird?
@ne555: I'm not sure what you think is wrong? They're just integers, unless two integers representing the same value can compare inequal...
0 0 0 0 0 0 0
is not an increasing sequence, but it is sorted.
Oh, I see what you mean - I would personally consider that both ways, but it does depend on the assignment's requirements.
Topic archived. No new replies allowed.