Advertisement
Tanina80

reverse stack 100/100

Jul 30th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4.  
  5. namespace _52
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var str = Console.ReadLine().Split(' ');
  12.            
  13.             Stack<int> stack = new Stack<int>();
  14.  
  15.             for (int i = 0; i <= str.Length-1; i++)
  16.             {
  17.                 try
  18.                 {
  19.                     int p = Int32.Parse(str[i]);
  20.  
  21.                     stack.Push(p);
  22.                 }
  23.                 catch
  24.                 {
  25.                 }
  26.             }
  27.  
  28.             while (stack.Count > 0)
  29.             { Console.Write("{0} ", stack.Pop());  }
  30.  
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement