Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace zadanie3__przykladowy_kolos
  8. {
  9.     class Program
  10.     {
  11.         static void Sortowanie(int[] T)
  12.         {
  13.          
  14.             for (int i = 0; i < T.Length; i++)
  15.             {
  16.                 for (int j = T.Length-1; j > 0 ; j--)
  17.                 {
  18.                     if(T[j] < T[j-1])
  19.                     {
  20.                         int temp = T[j];
  21.                         T[j] = T[j - 1];
  22.                         T[j - 1] = temp;
  23.                     }
  24.                 }
  25.             }
  26.         }
  27.  
  28.         static void wyswietl(int[] tab)
  29.         {
  30.             for (int i = 0; i < tab.Length; i++)
  31.             {
  32.                 Console.Write(tab[i] + " ");
  33.             }
  34.             Console.WriteLine();
  35.         }
  36.         static void Main(string[] args)
  37.         {
  38.             int[] T = { 1, 2, 3, 2, 3, 1, 1, 1, 2, 2, 3 };
  39.             wyswietl(T);
  40.             Sortowanie(T);
  41.             wyswietl(T);
  42.             Console.ReadKey();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement