desislava_topuzakova

2. Сортиране на числа

Mar 13th, 2022
963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _2._Sort_Numbers
  6. {
  7.     internal class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> numbers = Console.ReadLine().Split(" ").Select(int.Parse).ToList(); //{8,2, 7, 3}
  12.             //ascending order -> нарастващ ред
  13.             numbers.Sort(); // {2, 3, 7, 8}
  14.  
  15.             //descending order -> намаляващ ред
  16.             /*numbers.Sort();
  17.             numbers.Reverse();*/
  18.  
  19.             Console.WriteLine(string.Join('<', numbers));
  20.         }
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment