Sum of largest 2-digit numbers from given 3 numbers Given 3 input numbers
public static int findSumeetSum(int input1, int input2, int input3)
{
var a1 = GetIntArray(input1);
var a2 = GetIntArray(input2);
var a3 = GetIntArray(input3);
var sum = MakeNumber(a1[0],a1[1])
+ MakeNumber(a2[0], a2[1])
+ MakeNumber(a3[0], a3[1]);
return sum;
}
static int[] GetIntArray(int num)
{
List<int> ls = new List<int>();
while (num > 0)
{
ls.Add(num % 10);
num = num / 10;
}
ls.Reverse();
var arr = ls.ToArray();
Array.Sort(arr);
Array.Reverse(arr);
return arr;
}
static int MakeNumber(int numA, int numB)
{
return numA * 10 + numB;
}
}