public static void main(String[] args) throws Exception {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
playcardsstack obj = new playcardsstack();
stackusingarray s1 = obj.new stackusingarray(n);
stackusingarray A1 = obj.new stackusingarray(n);
stackusingarray B = obj.new stackusingarray(n);
int q = scn.nextInt();
int[] A = new int[n];
for (int i = 0; i < n; i++) {
A[i] = scn.nextInt();
}
play(A, q, s1, A1, B, n);
}
public static void play(int[] A, int q, stackusingarray s1, stackusingarray A1, stackusingarray B, int n)
throws Exception {
for (int i = 0; i < A.length; i++) {
s1.push(A[i]);
}
int tp;
int j = 1;
while (j <= q) {
for (int k = 1; k <=n; k++) {
while (!s1.isempty()) {
tp = s1.pop();
if (tp % 2 == 0) {
B.push(tp);
} else {
A1.push(tp);
}
}
}
j++;
}
B.display();
A1.display();
}
test case for this question playing card in stack is failing …i think i am going wrong in division by ith prime case…plzz check