kirililchev3

Square Numbers Linq solution

Jun 9th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace sad
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             List<int> numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  11.  
  12.             numbers.RemoveAll(num => Math.Sqrt(num) != (int)Math.Sqrt(num));
  13.  
  14.             Console.WriteLine(string.Join(" ",numbers.OrderByDescending(x => x)));
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment