Given an integer A which denotes the number of people standing in the queue. A selection process follows a rule where people standing on even positions are selected. Of the selected people a queue is formed and again out of these only people on even position are selected. This continues until we are left with one person. Find and return the position of that person in the original queue.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int A=10,p=0,i;
vector<bool> mark(A+1,true);
mark[0]=false;
for(i=0;i<=A;i=i+2)
{
p++;
if(p==2)
{
mark[i]=false;
p=0;
}
}
for(int j=0;j<A;j++)
{
cout<<mark[j];
}
for(i=0;i<A;i++)
{
if(mark[i]==true)
{
cout<<i<<endl;
}
}
}
i tried this but it only works for the first set of even numbers ps:i am new here so please forgive me if i asked in a wrong way