-
Notifications
You must be signed in to change notification settings - Fork 0
/
MathUtil.cs
40 lines (32 loc) · 1016 Bytes
/
MathUtil.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Arrays
{
public static class MathUtil
{
public static double Average(int a, int b)
{
return a + b / 2;
}
public static void GetLargestNumber(int input)
{
List<int> list = new List<int>();
int AllDigits = input % 1000;
int firstDigit = Convert.ToInt32(AllDigits.ToString().Substring(0, 1));
list.Add(firstDigit);
int lastTwoDigits = input % 100;
int middleDigit = Convert.ToInt32(lastTwoDigits.ToString().Substring(0, 1));
list.Add(middleDigit);
int lastDigit = input % 10;
list.Add(lastDigit);
var sortedItems = list.OrderByDescending(x => x).ToList();
foreach (var item in sortedItems)
{
Console.WriteLine(item.ToString());
}
Console.ReadLine();
}
}
}