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;
- namespace ConsoleApplication6
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string[] inputArray = input.Split(' ');
- int[] array = new int[inputArray.Length];
- for (int i = 0; i < inputArray.Length; i++)
- {
- array[i] = int.Parse(inputArray[i]);
- }
- bool b = true;
- do
- {
- b = true;
- for (int i = 1; i < array.Length; i++)
- {
- if (array[i-1] > array[i])
- {
- int value = array[i];
- array[i] = array[i - 1];
- array[i - 1] = value;
- }
- }
- for (int j = 1; j < array.Length; j++)
- {
- if (array[j - 1] > array[j])
- {
- b = false;
- }
- }
- } while (b != true);
- foreach (var item in array)
- {
- Console.Write(item + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment