Advertisement
Tanina80

stack4

Jul 29th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace videoYoutube
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string str = Console.ReadLine();
  14.             Stack<int> stack = new Stack<int>();
  15.             int length = 0;
  16.  
  17.  
  18.             for (int i = 0; i<=str.Length-1; i++)
  19.             {
  20.                 stack.Push(length); //пълни стек с броя чарове, позиции в стринга
  21.                 length++;
  22.             }
  23.             length = str.Length-1;
  24.  
  25.             while (stack.Count > 0)
  26.            {
  27.                stack.Pop(); //намялява стойността на стек каунт контролираща уайл цикъла
  28.                Console.Write(str[length]);
  29.                length--;
  30.            }
  31.  
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement