Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- List<double> numbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(double.Parse).ToList();
- List<double> squareNumbers = new List<double>();
- for (int i = 0; i < numbers.Count; i++)
- {
- if ((numbers[i] == MathPow(MathSqrt(numbers[i])) && numbers[i]!=0))
- {
- squareNumbers.Add(numbers[i]);
- }
- }
- squareNumbers.Sort();
- squareNumbers.Reverse();
- Console.WriteLine(string.Join(" ", squareNumbers));
- }
- static double MathPow(double num)
- {
- double result;
- result = num*num;
- return result;
- }
- public static double MathSqrt(double num)
- {
- if (num == 0)
- {
- return 0;
- }
- double n = (num / 2) + 1;
- double n1 = (n + num / n) / 2;
- while (n1 < n)
- {
- n = n1;
- n1 = (n + (num / n)) / 2;
- } // end while
- return n;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement