0
[SOLVED] Wrong C# 78.2 exercise evaluation?
In C# course, Stack exercise, don't know why it doesn't works: using System; using System.Collections.Generic; namespace SoloLearn { class Program { static void Main(string[] args) { var evenNums = new Stack<int>(); evenNums.Push(4); evenNums.Push(8); evenNums.Push(6); int num = Convert.ToInt32(Console.ReadLine()); evenNums.Push(num); Console.WriteLine("Checking the last number: " + num); if ( num % 2 != 0 ) Console.WriteLine(
quot;{evenNums.Pop()}: Removed"); for (int i = 0; i < evenNums.Count; i++) Console.Write(quot;{evenNums.Pop()} "); } } }2 Answers
+ 6
Kiwwi#
In loop no need to remove again. You just have to print the value.
if ( num % 2 != 0 )
Console.WriteLine(quot;{evenNums.Pop()}: Removed");
foreach (int i in evenNums)
Console.Write(i + " ");
+ 1
I Am Groot ! now understand, it was shortening it on the fly so doesn't match all