Advertisement
Guest User

Untitled

a guest
Jan 27th, 2023
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. class Program
  7. {
  8.     static void Main()
  9.     {
  10.         string[] stringList = Console.ReadLine().Split(' ');
  11.         int[] intList = new int[stringList.Length];
  12.         int temp;
  13.  
  14.         for (int i = 0; i < stringList.Length; i++)     //converting array loop(string to int)
  15.         {
  16.             temp = int.Parse(stringList[i]);
  17.             intList[i] = temp;
  18.         }
  19.  
  20.         for (int k = 0; k < intList.Length; k++)   //sorting array loop
  21.         {
  22.             for (int n = 0; n < k; n++)
  23.             {
  24.                 if (intList[n] < intList[k])
  25.                 {
  26.                     temp = intList[k];
  27.                     intList[k] = intList[n];
  28.                     intList[n] = temp;
  29.                 }
  30.             }
  31.         }
  32.  
  33.         for (int j = 0; j < intList.Length; j++)    //converting array loop (int to string)
  34.         {
  35.             temp = intList[j];
  36.             stringList[j] = Convert.ToString(temp);
  37.         }
  38.  
  39.         string output = string.Join(", ", stringList);
  40.         Console.WriteLine(output);
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement