0
Stack & Queue
The program you are given defines the evenNums stack and pushes 3 even numbers (6, 8 and 4) onto it. The 4th number is taken from the user and also pushed. But we need to check whether it is also an even number. Complete the program to perform that check process, and if the last pushed number N isn't even, remove it from stack and output "N: Removed" (see sample output). At the end, output all the elements of the stack, separated by spaces. Sample Input 1 Sample Output Checking the last number: 1 1: Removed 6 8 4 Anyone take it a look my code please, it works for me but it does not pass the all test. any suggest please https://code.sololearn.com/ca13a0A23a21
1 ответ
+ 1
I see what's causing the issue. You need to add a space right after the colon in line 19. So Console.WriteLine("Checking the last number:space" + num). Then again on line 24 Console.WriteLine(num + ":spaceRemoved"). I would also suggest switching your lines 24 and 25 so that the statement is printed after its removed from the stack. You should be good!