Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class SortingArray
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int[] arr = new int[n];
- for (int i = 0; i < n; i++)
- {
- arr[i] = int.Parse(Console.ReadLine());
- }
- int minValue = 0;
- int index = 0;
- for (int i = 0; i < (n - 1); i++)
- {
- int currentValue = arr[i];
- index = i;
- for (int j = (i + 1); j < n; j++)
- {
- if (arr[j] < currentValue)
- {
- minValue = arr[j];
- index = j;
- }
- }
- if (index != i)
- {
- arr[index] = currentValue;
- arr[i] = minValue;
- }
- }
- foreach (var num in arr)
- {
- Console.Write(num + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement