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];
- List<int> sortList = new List<int>();
- for (int i = 0; i < n; i++)
- {
- arr[i] = int.Parse(Console.ReadLine());
- }
- List<int> arrList = arr.ToList();
- while (arrList.Count > 0)
- {
- int min = arrList[0];
- for (int j = 0; j < arrList.Count; j++)
- {
- if (arrList[j] <= min)
- {
- min = arrList[j];
- }
- }
- sortList.Add(min);
- arrList.Remove(min);
- }
- Console.WriteLine();
- foreach (var num in sortList)
- {
- Console.Write(num + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement