Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. namespace @new
  3. {
  4.     class Program
  5.     {
  6.         public static void Main()
  7.         {
  8.             string numbers = Console.ReadLine();
  9.             char[] arr1 = numbers.Replace(" ", string.Empty).Replace(",", string.Empty).ToCharArray();
  10.  
  11.  
  12.             int[] arr = new int[arr1.Length];
  13.  
  14.             for (int i = 0; i < arr1.Length; i++)
  15.             {
  16.                 arr[i] = Convert.ToInt32(new string(arr1[i], 1));
  17.             }
  18.  
  19.             int temp;
  20.  
  21.  
  22.             for (int i = 0; i < arr.Length - 1; i++)
  23.  
  24.  
  25.                 for (int j = i + 1; j < arr.Length; j++)
  26.  
  27.  
  28.                     if (arr[i] < arr[j])
  29.                     {
  30.  
  31.                         temp = arr[i];
  32.                         arr[i] = arr[j];
  33.                         arr[j] = temp;
  34.                     }
  35.  
  36.  
  37.             for (int i = 0; i < arr.Length; i++)
  38.             {
  39.                 Console.Write($"{i}, ");
  40.             }
  41.  
  42.  
  43.  
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement