Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using System.Collections;
- using System.Threading.Tasks;
- using System.Collections.Generic;
- /* Kolokwium 1 */
- /* [1] Ile jest par rownych liczb dwumiarowych, ktory sume jest liczba pierwsza
- * [2] Wygenerowac tablica, 10 elementowa zlozone 2 cyfr
- * [3] Ile jest latercyjnych web, ktorych suma rowne 0
- /* Kolokwium 2 */
- /* [1] Rekurecyjne i iterecyjne znalezc n = n-1, n <= 3 || an-1 + an-2 - 2^n, n > 3 */
- /* [2] Wygenerowac macierz n x k(n,k <2,5>) zlozonych z cyfr. Ile wynosi najwieksza liczba elementow parzystych w wierszu kolumnie lub przekatnej */
- /* Kolokwium 3 */
- /* [1] Z dowonlego stosu Stack <int> przepisac elementy parzyste do Queue<int> Nieparzyste przyrownac na stos */
- /* [2] Napisac konstruktor Stos(int r, int n) ktory tworzy stos o rozmiarze r i dodaje do niego r losowych cyfr */
- /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
- namespace Kolokwium2
- {
- class Program
- {
- static void K3Z1()
- {
- /* Kolos 3 Zadanie 1 */
- Stack<int> stack1 = new Stack<int>();
- Stack<int> stack2 = new Stack<int>();
- Queue<int> kolejka = new Queue<int>();
- stack1.Push(1);
- stack1.Push(2);
- stack1.Push(3);
- stack1.Push(4);
- foreach (int i in stack1)
- {
- if (i % 2 == 0)
- {
- kolejka.Enqueue(i);
- Console.Write("Parzyste:" + " " + i + "\n");
- }
- else
- {
- stack2.Push(i);
- }
- }
- stack1.Clear();
- foreach (int i in stack2)
- {
- stack1.Push(i);
- Console.WriteLine("Nieparzyste:" + " " + i);
- }
- Console.ReadLine();
- }
- static void K1Z2()
- {
- Random rand = new Random();
- int[] array = new int[10];
- for(int a = 0; a < array.Length; a++)
- {
- array[a] = rand.Next(0, 10);
- Console.Write("Elementy w tej tablice:" + " " + array[a]);
- }
- }
- static void Main(string[] args)
- {
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement