Playing with card stack


I am getting runtime error. Can you help me out with this question

@abhishekjohri98,
Error in line 25 for (int i = n-1; i >= 0; i --) should be the correct loop. After that, 4 is being considered as a prime. So please look into that as well

https://ide.codingblocks.com/s/194443 I have made the said changes still I am unable to pass all test cases Can you help me with my mistake

@abhishekjohri98,

In this question we will have to use three stacks at a time.

Stack1 is for storing the given cards.

For a particular ith iteration stack2 stores that cards which are divisible by ith prime number and rest of the cards are stored in stack3.

For the next iteration stack3 is now stack 1 and same steps are repeated.

Here Prime is the array of prime numbers.

For every iteration print the cards in stack2 and after the queries are over print the cards in stack1.

How can we use array of prime numbers and also how to assign stack3 to stack1 after the iteration

@abhishekjohri98,
I have corrected your code: https://ide.codingblocks.com/s/195467 kindly understand the changes