Here is my function. I am wondering why I cant perform simple math operations on the two int variables
int sockMerchant(int n, vector<int> ar) {
int pairs;
for (int i = 1; i <= 100 ; i++) { //for every number ("Color") between 1 and 100
for (int j = 0; j < n; j++) { //iterate thru array to look for it
if (ar[j] == i) { //once found,
for (int k = j; k < n ; k++) { //count how many of that number is there
if (ar[k] == i) {
int count;
count++;
}
}
count = (count/2);
pairs = (pairs+count);
}
}
}
return pairs;
}
Here is the error recieved:
solution.cc: In function ‘int sockMerchant(int, std::vector<int>)’:
solution.cc:20:27: error: invalid operands of types ‘<unresolved overloaded
function type>’ and ‘int’ to binary ‘operator/’
count = (count/2);
~~~~~^~
solution.cc:21:27: error: invalid operands of types ‘int’ and ‘<unresolved
overloaded function type>’ to binary ‘operator+’
pairs = (pairs+count);
~~~~~^~~~~~