Oct 31, 2013 at 12:05am UTC
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.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #include <iostream>
using namespace std;
bool increasing(vector< int> arr, int numbers, int size);
while (cin >> n)
vector< int> arr(n);
for ( int i = 0; i < n; i++)
cin >> arr[i];
cout << (increasing(arr) ? "increasing" : "not increasing") << endl;
bool increasing(vector< int> arr, int numbers, int size)
int last = numbers;
for( unsigned int i = 0; i < (arr.size()); ++i)
if(numbers[i] < last)
last = numbers[i];
Last edited on
Oct 31, 2013 at 12:07am UTC
Oct 31, 2013 at 12:23am UTC
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.
2 3 auto sorted = original;
std::cout << std::boolalpha << (sorted == original) << std::endl;
Last edited on
Oct 31, 2013 at 12:24am UTC
Oct 31, 2013 at 1:00am UTC
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
count the arguments
¿don't you see anything weird?
Oct 31, 2013 at 1:39am UTC
@ne555: I'm not sure what you think is wrong? They're just integers, unless two integers representing the same value can compare inequal...
Oct 31, 2013 at 3:01am UTC
0 0 0 0 0 0 0
is not an increasing sequence, but it is sorted.
Oct 31, 2013 at 3:06am UTC
Oh, I see what you mean - I would personally consider that both ways, but it does depend on the assignment's requirements.