Advertisement
desislava_topuzakova

Problem 1. Обръщане на числа със стека

Jun 7th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace AlgorithmsOverStructureData
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int n = int.Parse(Console.ReadLine());
  12. Stack<int> stack = new Stack<int>();
  13. for (int number = 1; number <= n; number++)
  14. {
  15. int value = int.Parse(Console.ReadLine()); // 1 2 3 4
  16. stack.Push(value); // 4 3 2 1
  17.  
  18. }
  19.  
  20. while (stack.Count > 0)
  21. {
  22. Console.Write(stack.Pop() + " ");
  23. }
  24.  
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement