I want to sort chopsticks by weight and I want the matching pair of chopstick at the end of program. Should I use sort algorithm? I want to sort it by weight means (e.g 110, 90, 110, 90) so in this case I got 2 pair. One having weight 90 and other having weight 110, but how can I track that? I know I have to use counter but how I don not know.
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool myChopsticks (int i, int j)
{
return (i<j);
}
int main()
{
int myintergers []= {90, 110, 90, 110};
vecotr<int> myvector(myintergers, myintergers+4);
vector<int>::iterator it;
sort (myvector.begin(), myvector.end()+2);
cout << "myvector contains:";
for (it=myvector.begin(); it!=myvector.end(); ++it)
cout << " " << *it; cout << endl;
return 0;
}