Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace podatkovnestruktire
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Stack<int> s = new Stack<int>();
  13. s.Push(2);
  14. s.Push(3);
  15. s.Push(4);
  16. s.Push(5);
  17. s.Push(6);
  18. s.Push(6);
  19. Stack<int> s1 = new Stack<int>();
  20. int v = s.Count;
  21. for (int i = 0; i < v; i++)
  22. {
  23.  
  24. if (i % 2 == 0)
  25. {
  26. s1.Push(s.Pop());
  27. }
  28. else
  29. {
  30. s.Pop();
  31. }
  32.  
  33. }
  34. Console.WriteLine(s1);
  35. Console.Read();
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement