Hey, i've just joined...having trouble with a vector question..
the question asks that if a you a range of numbers, eg.6, we want to erase every third number:
eg. 123456
12456
1245
125
15
1
and out we get should be as in this case 1.
so far what i have is:
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
void main()
{
// Variable declarations
int i;
int current=0;
int cal;
int numSuitors;
cout << "Enter the number of suitors" << endl;
cin >> numSuitors;
vector<int> suitors(numSuitors);
for (i=0; i<numSuitors; i++)
{
suitors[i] = i+1; // Number each suitor's position
}
//cal= modf ((current+2), &numSuitors);
current=cal;
cal=2;
cout<<"To win the princess, you should stand in position ";
for (i=0; i<suitors.size(); i++)
{
suitors.erase(suitors.begin()+cal);
suitors[i];
}
//cout<< suitors[0]<<endl;
}
help is appreciated!!