Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Averages-Mean-angle/C-sharp/averages-mean-angle.cs
Normal file
19
Task/Averages-Mean-angle/C-sharp/averages-mean-angle.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using static System.Math;
|
||||
class Program
|
||||
{
|
||||
static double MeanAngle(double[] angles)
|
||||
{
|
||||
var x = angles.Sum(a => Cos(a * PI / 180)) / angles.Length;
|
||||
var y = angles.Sum(a => Sin(a * PI / 180)) / angles.Length;
|
||||
return Atan2(y, x) * 180 / PI;
|
||||
}
|
||||
static void Main()
|
||||
{
|
||||
Action<double[]> printMean = x => Console.WriteLine("{0:0.###}", MeanAngle(x));
|
||||
printMean(new double[] { 350, 10 });
|
||||
printMean(new double[] { 90, 180, 270, 360 });
|
||||
printMean(new double[] { 10, 20, 30 });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue