Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SortingExample
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] liczba = new int[100];
- //int[] liczba = new int[1000];
- //int[] liczba = {89, 76, 45, 92, 67, 12, 99, 125, 23, 44, 456, 13, 1, 9};
- int zlicz = 0;
- int temp;
- int numLength = liczba.Length;
- //non Sorted array
- Console.WriteLine("Tablica przed sortem");
- foreach (int num in liczba)
- {
- Console.Write("\t {0}", num);
- }
- //sorting an array
- for (int i = 0; (i <= (numLength - 1)); i++)
- {
- for (int j = 0; j < (numLength - 1); j++)
- {
- if (liczba[j + 1] < liczba[j])
- {
- temp = liczba[j];
- liczba[j] = liczba[j + 1];
- liczba[j + 1] = temp;
- }
- }
- zlicz++;
- }
- //Sorted array
- Console.WriteLine("\nTablica po sorcie");
- foreach (int num in liczba)
- {
- Console.Write("\t {0}", num);
- }
- Console.WriteLine("\n Ilość operacji {0}", zlicz);
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement