Advertisement
VelizarAvramov

06. Square Numbers

Dec 2nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _06._Square_Numbers
  6. {
  7.     class SquareNumbers
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> numbers = Console.ReadLine()
  12.                 .Split(' ')
  13.                 .Select(s => int.Parse(s))
  14.                 .ToList();
  15.  
  16.             List<int> selected = numbers.Where(num => Math.Sqrt(num) == (int)Math.Sqrt(num)).ToList();
  17.  
  18.             selected = selected.OrderByDescending(a => a).ToList();
  19.             Console.WriteLine(string.Join(" ", selected));
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement