Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace prostoChislo
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.             int[] sortedArray = new int[arr.Length];
  13.            
  14.             for (int i = 0; i < arr.Length; i++)
  15.             {
  16.                 int currmax = int.MinValue;
  17.                 int maxIndex = i;
  18.                 for (int j = 0; j <arr.Length; j++)
  19.                 {
  20.                     if (currmax<arr[j])
  21.                     {
  22.                         currmax = arr[j];
  23.                         maxIndex = j;
  24.                     }
  25.                 }
  26.                 sortedArray[i] = currmax;
  27.                 arr[maxIndex] = int.MinValue;
  28.             }
  29.             Console.WriteLine(string.Join(" ",sortedArray));
  30.         }
  31.  
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement