-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyMath.cs
104 lines (83 loc) · 2.07 KB
/
MyMath.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyDistanceCalculator
{
public class MyMath
{
public int Sum(int[] data)
{
int result = 0;
foreach (int item in data)
{
result = result + item;
}
return result;
}
public double SumDouble(double[] data)
{
double result = 0;
foreach (double item in data)
{
result = result + item;
}
return result;
}
public int Subtraction(int a, int b)
{
return a - b;
}
public double SubtractionDouble(double a, double b)
{
return a - b;
}
public int Multiply(int[] numbers)
{
int result = 1;
foreach (int item in numbers)
{
result = result * item;
}
return result;
}
public double MultiplyDouble(double[] numbers)
{
double result = 1;
foreach (double item in numbers)
{
result = result * item;
}
return result;
}
public int Divide(int a, int b)
{
if (b == 0)
throw new ArgumentException("Not divide for 0");
return a / b;
}
public double DivideDouble(double a, double b)
{
if (b == 0)
throw new ArgumentException("Not divide for 0");
return a / b;
}
public int CalcChange(int a, int b)
{
return a % b;
}
public int ElevA(int a, int b)
{
return Convert.ToInt32(Math.Pow(a, b));
}
public double ElevDouble(double a, double b)
{
return Math.Pow(a, b);
}
public double CalcSqrt(double number)
{
return Math.Round(Math.Sqrt(number), 2);
}
}
}