-1

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!!

Edited by Nick Evan: Added code-tags, split thread

Votes + Comments
Start your own thread instead of hijacking someone else's thread.
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.