Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class Program
- {
- public static void Main()
- {
- Queue<int> numbersq = new Queue<int>();
- Stack<int> odds = new Stack<int>();
- Stack<int> evens = new Stack<int>();
- Console.Write("Enter n: ");
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- int num = int.Parse(Console.ReadLine());
- numbersq.Enqueue(num);
- }
- while (numbersq.Count != 0)
- {
- int num = numbersq.Dequeue();
- if (num % 2 == 0)
- {
- evens.Push(num);
- }
- else
- {
- odds.Push(num);
- }
- }
- Console.Write("Odd stack: ");
- while (odds.Count != 0)
- {
- Console.Write(odds.Pop() + ", ");
- }
- Console.Write("\nEven stack: ");
- while (evens.Count != 0)
- {
- Console.Write(evens.Pop() + ", ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement