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 = false;
- while (b != true)
- {
- b = true;
- for (int i = 0; i < array.Length - 1; i++)
- {
- if (array[i] > array[i + 1])
- {
- int help;
- help = array[i];
- array[i] = array[i + 1];
- array[i + 1] = help;
- }
- }
- for (int j = 0; j < array.Length - 1; j++)
- {
- if (array[j] > array[j + 1])
- {
- b = false;
- }
- }
- }
- List<int> print = array.ToList();
- for (int i = 0; i < print.Count - 1; i++)
- {
- if (print[i] == print[i + 1])
- {
- print.RemoveAt(i);
- }
- }
- print.ForEach(i => Console.Write(i + " "));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment