getting wrong answer ,please help
here is the link
https://ide.codingblocks.com/s/73016
Playing with stacks(in stack)
@Vijay hey vijay there is some mistake
use prime sieve
now the algorithm of this question
take three stack
for i=0 to n
take input in the first stack
now apply loop from i=0 to q
if stack1.empty()
break;
take new variable as cur which hold prime at i i.e prime[i]
while(!stack1.empty())
take a new input as ele=stack.top();
stack.pop();
if(ele%cur==0)
push to stack2
else
push to stack3
while(!stack2.empty())
{
print the value at top of stack2
pop value one by one
}
now copy value of stack3 to stack1
while(!stack3.empty())
{
print value at top of stack3
pop value one by one
}
loop stop here which applied above for i=0 to q
while(!stack1.empty())
print top value of stack 1
pop the value one by one
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.