Facebook
From Bitty Goat, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 174
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4.  
  5. namespace ConsoleApp33
  6. {
  7.     class Program
  8.     {
  9.  
  10.  
  11.         //----------ZADANIE PIERWSZE--------------
  12.         static void przepisz(Stack<int> s, Queue<int> k)
  13.         {
  14.             Stack<int> s2 = new Stack<int>();
  15.             int x;
  16.             while (s.TryPop(out x))
  17.             {
  18.                 k.Enqueue(x);
  19.                 if (x % 2 == 0) s2.Push(x);
  20.             }
  21.  
  22.             while (s2.TryPop(out x))
  23.             {
  24.                 s.Push(x);
  25.             }
  26.         }
  27.         static void Parzystosc()
  28.         {
  29.             int x;
  30.             Queue<int> k = new Queue<int>();
  31.             Stack<int> s = new Stack<int>();
  32.  
  33.             for (int i = 0; i < 10; i++)
  34.             {
  35.                 s.Push(i);
  36.             }
  37.             przepisz(s, k);
  38.             Console.WriteLine("Zadnie pierwsze");
  39.             Console.WriteLine("Queue: ");
  40.             while (k.TryDequeue(out x))
  41.             {
  42.                 Console.Write(x + " ");
  43.             }
  44.             Console.WriteLine();
  45.             Console.WriteLine("Parzyste: ");
  46.             while (s.TryPop(out x))
  47.             {
  48.                 Console.Write(x + " ");
  49.             }
  50.         }
  51.  
  52.  
  53.         //----------KONIEC---------------
  54.  
  55.         //--------ZADANIE DRUGIE----------
  56.  
  57.         static void Slownik()
  58.         {
  59.             Dictionary<string, string> DictionaryUsers = new Dictionary<string, string>();
  60.             SortedDictionary<string, string> SortedDictionaryUsers = new SortedDictionary<string, string>();
  61.             SortedList<string, string> SortedListUsers = new SortedList<string, string>();
  62.  
  63.             Random rand = new Random();
  64.             string login = "";
  65.             string haslo = "";
  66.             int losuj;
  67.             List<string> logins = new List<string>();
  68.             string[] pass = new string[10000];
  69.  
  70.  
  71.            
  72.  
  73.         }
  74.         //-------------KONIEC-------------------
  75.         //-----------ZADANIE TRZECIE------------
  76.         static void Przenoszenie()
  77.         {   string x;
  78.             int y;
  79.             Queue<int> kolejka = new Queue<int>();
  80.             for (int i = 0; i < 10; i++)
  81.             {
  82.  
  83.                 kolejka.Enqueue(i);
  84.             }
  85.             Stack<string> stos = CopyFrom(kolejka);
  86.  
  87.             Console.WriteLine("nZadanie trzecie");
  88.             Console.WriteLine("Queue: ");
  89.             while (kolejka.TryDequeue(out y))
  90.             {
  91.                 Console.Write(y + " ");
  92.             }
  93.             Console.Write("nStack: n");
  94.             while (stos.TryPop(out x))
  95.             {
  96.                 Console.Write(x + " ");
  97.             }
  98.  
  99.         }
  100.  
  101.         static Stack<string> CopyFrom(Queue<int> kolejka)
  102.         {
  103.             Stack<string> stos = new Stack<string>();
  104.             Stack<int> stos2 = new Stack<int>();
  105.             Queue<int> kolejka2 = new Queue<int>();
  106.             int x;
  107.             Console.WriteLine();
  108.             while (kolejka.TryDequeue(out x))
  109.             {
  110.                 stos2.Push(x);
  111.                 kolejka2.Enqueue(x);
  112.             }
  113.             while (stos2.TryPop(out x))
  114.             {
  115.                 stos.Push(x.ToString());
  116.             }
  117.             while (kolejka2.TryDequeue(out x))
  118.             {
  119.                 kolejka.Enqueue(x);
  120.             }
  121.  
  122.             return stos;
  123.         }
  124.         //--------------KONIEC--------------
  125.         static void Main(string[] args)
  126.         {
  127.             Parzystosc();
  128.             Slownik();
  129.             Przenoszenie();
  130.             Console.ReadKey();
  131.  
  132.  
  133.         }
  134.     }
  135. }