Advertisement
Tanina80

stack3

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