mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
18 lines
396 B
C#
18 lines
396 B
C#
using System;
|
|
|
|
public class Kata
|
|
{
|
|
public static int[] SquareOrSquareRoot(int[] array)
|
|
{
|
|
int[] new_array = new int[array.Length];
|
|
|
|
for (int i = 0, max = array.Length; i < max; i++)
|
|
{
|
|
double root = Math.Sqrt(array[i]);
|
|
if (root - (int) root <= double.Epsilon) new_array[i] = (int) root;
|
|
else new_array[i] = array[i] * array[i];
|
|
}
|
|
|
|
return new_array;
|
|
}
|
|
}
|