Advertisement
Guest User

1111

a guest
Jan 28th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Collections;
  5. using System.Threading.Tasks;
  6. using System.Collections.Generic;
  7.  
  8. /* Kolokwium 1 */
  9. /* [1] Ile jest par rownych liczb dwumiarowych, ktory sume jest liczba pierwsza
  10. * [2] Wygenerowac tablica, 10 elementowa zlozone 2 cyfr
  11. * [3] Ile jest latercyjnych web, ktorych suma rowne 0
  12. /* Kolokwium 2 */
  13. /* [1] Rekurecyjne i iterecyjne znalezc n = n-1, n <= 3 || an-1 + an-2 - 2^n, n > 3 */
  14. /* [2] Wygenerowac macierz n x k(n,k <2,5>) zlozonych z cyfr. Ile wynosi najwieksza liczba elementow parzystych w wierszu kolumnie lub przekatnej */
  15. /* Kolokwium 3 */
  16. /* [1] Z dowonlego stosu Stack <int> przepisac elementy parzyste do Queue<int> Nieparzyste przyrownac na stos */
  17. /* [2] Napisac konstruktor Stos(int r, int n) ktory tworzy stos o rozmiarze r i dodaje do niego r losowych cyfr */
  18. /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
  19.  
  20. namespace Kolokwium2
  21. {
  22. class Program
  23. {
  24. static void K3Z1()
  25. {
  26. /* Kolos 3 Zadanie 1 */
  27. Stack<int> stack1 = new Stack<int>();
  28. Stack<int> stack2 = new Stack<int>();
  29. Queue<int> kolejka = new Queue<int>();
  30.  
  31. stack1.Push(1);
  32. stack1.Push(2);
  33. stack1.Push(3);
  34. stack1.Push(4);
  35.  
  36. foreach (int i in stack1)
  37. {
  38. if (i % 2 == 0)
  39. {
  40. kolejka.Enqueue(i);
  41. Console.Write("Parzyste:" + " " + i + "\n");
  42. }
  43. else
  44. {
  45. stack2.Push(i);
  46. }
  47. }
  48.  
  49. stack1.Clear();
  50.  
  51. foreach (int i in stack2)
  52. {
  53. stack1.Push(i);
  54. Console.WriteLine("Nieparzyste:" + " " + i);
  55. }
  56. Console.ReadLine();
  57. }
  58.  
  59. static void K1Z2()
  60. {
  61. Random rand = new Random();
  62. int[] array = new int[10];
  63.  
  64. for(int a = 0; a < array.Length; a++)
  65. {
  66. array[a] = rand.Next(0, 10);
  67. Console.Write("Elementy w tej tablice:" + " " + array[a]);
  68. }
  69. }
  70. static void Main(string[] args)
  71. {
  72. Console.ReadKey();
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement