walec91

Ćwiczenia #6

Jan 9th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.64 KB | None | 0 0
  1. using System;
  2. namespace ConsoleApp20
  3. {
  4.     internal class Program
  5.     {
  6.         private static void Main(string[] args)
  7.         {
  8.             #region sortowanie bąbelkowe
  9.             //int[] tab = { 4, 3, -3, 2, 9, 1, -2, 8, 3, 0 };
  10.             //int tmp;
  11.             //int i = 0;
  12.  
  13.             //for (int j = 0; j < 9; j++)
  14.             //{
  15.             //    for (i = 0; i < 9; i++)
  16.             //    {
  17.             //        if (tab[i] > tab[i + 1])
  18.             //        {
  19.             //            tmp = tab[i]; tab[i] = tab[i + 1]; tab[i + 1] = tmp;
  20.             //        }
  21.             //    }
  22.             //}
  23.  
  24.             //for (i = 0; i <= 9; i++)
  25.             //{
  26.             //    Console.Write(tab[i] + " ");
  27.             //}
  28.  
  29.             //Console.ReadKey();
  30.             #endregion
  31.             #region tablica dwuwymiarowa
  32.             //int[,] t1 = {
  33.             //            { 1, 2, 6, 2, 7 },
  34.             //            { 2, 2, 4, 4, 5 },
  35.             //            { 3, 6, 3, 8, 4 },
  36.             //            { 4, 8, 8, 4, 1 },
  37.             //            { 5, 2, 6, 3, 1 }
  38.             //            };
  39.  
  40.             //int i = 0, su = 0;
  41.             //int kol;
  42.             //Console.WriteLine("Która kolumna?");
  43.             //kol = Convert.ToInt16(Console.ReadLine());
  44.  
  45.             //for (i = 0; i < 5; i++)
  46.             //{
  47.             //    su += t1[i, kol - 1];
  48.             //}
  49.             //Console.WriteLine(su);
  50.  
  51.             //Console.ReadKey();
  52.             #endregion
  53.             #region tablica znakowa
  54.             //int ile = 0;
  55.             //string tekst = "Programowanie w języku C sharp to istna szarpanina";
  56.  
  57.             //for (int n = 0; n < tekst.Length; n++)
  58.             //{
  59.             //    if (tekst[n] == ' ')      //sprawdzanie każdego znaku po kolei
  60.             //    {
  61.             //        ile++;
  62.             //    }
  63.             //}
  64.             //Console.WriteLine("Słów jest: " + (1 + ile));
  65.  
  66.             //Console.ReadKey();
  67.             #endregion
  68.             #region wstawianie
  69.             //string ja = "Kacper Walkowski";
  70.  
  71.             //ja = ja.Insert(ja.IndexOf(' '), " Maciej"); // ja.Insert(po którym znaku chcemy wstawić, "co chcemy wstawić")
  72.             //Console.WriteLine(ja);
  73.  
  74.             //Console.ReadKey();
  75.             #endregion
  76.             #region zamiana
  77.             //string t1 = "AA-1997-12-12-klej";
  78.             //string t2 = "ZZZ-2004-11-23-farba";
  79.  
  80.             //string t11;
  81.             //string t21;
  82.  
  83.             //t11 = t1.Substring(t1.IndexOf("-") + 1, 10);
  84.             //t21 = t2.Substring(t2.IndexOf("-") + 1, 10);
  85.  
  86.             //Console.WriteLine(t11);
  87.             //Console.WriteLine(t21);
  88.  
  89.             //Console.ReadKey();
  90.             #endregion
  91.             #region 4
  92.             byte ile;
  93.             Console.WriteLine("ile osób będzie?");
  94.             ile = Convert.ToByte(Console.ReadLine());
  95.             int i = 0;
  96.             string[,] tab = new string[ile, 2];
  97.  
  98.             do
  99.             {
  100.                 Console.WriteLine("podaj nazwisko");
  101.                 tab[i, 0] = Console.ReadLine();
  102.                 Console.WriteLine("podaj imię");
  103.                 tab[i, 1] = Console.ReadLine();
  104.                 i++;
  105.             } while (i < ile);
  106.  
  107.             string kto;
  108.             Console.WriteLine("Czyjego imienia szukasz?");
  109.             kto = Console.ReadLine();
  110.  
  111.             for (i = 0; i < ile; i++)
  112.             {
  113.                 if (tab[i, 0] == kto)
  114.                 {
  115.                     Console.WriteLine(tab[i, 1]);
  116.                 }
  117.             }
  118.  
  119.             Console.ReadKey();
  120.             #endregion
  121.         }
  122.     }
  123. }
Add Comment
Please, Sign In to add comment