MiroslavKisov

ReverseNumbersWithStack

Jan 16th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ReverseNumberWithStack
  6. {
  7.     public class StartUp
  8.     {
  9.         public static void Main()
  10.         {
  11.             var input = Console.ReadLine()
  12.                 .Split(new char[] {' '},StringSplitOptions.RemoveEmptyEntries)
  13.                 .Select(int.Parse)
  14.                 .ToArray();
  15.             Stack<int> stack = new Stack<int>(input);
  16.             for (int i = 0; i < input.Length; i++)
  17.             {
  18.                 Console.Write(stack.Pop() + " ");
  19.             }
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment