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[] number = { 89, 76, 45, 92, 67, 12, 99 };
- bool flag = true;
- int temp;
- int numLength = number.Length;
- Console.WriteLine("Tablica przed sortem");
- foreach (int num in number)
- {
- Console.Write("\t {0}", num);
- }
- //sorting an array
- for (int i = 1; (i <= (numLength - 1)) && flag; i++)
- {
- flag = false;
- for (int j = 0; j < (numLength - 1); j++)
- {
- if (number[j + 1] < number[j])
- {
- temp = number[j];
- number[j] = number[j + 1];
- number[j + 1] = temp;
- flag = true;
- }
- }
- }
- //Sorted array
- Console.WriteLine("Tablica po sorcie");
- foreach (int num in number)
- {
- Console.Write("\t {0}", num);
- }
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement