CSharp · Console
using System;
public class Program
{
public static void Main()
{
int first = int.Parse(Console.ReadLine());
int second = int.Parse(Console.ReadLine());
int third = int.Parse(Console.ReadLine());
int fourth = int.Parse(Console.ReadLine());
int firstrs = first + third;
int secondrs = first + fourth;
int thirdrs = second + third;
int fourthrs = second + fourth;
int fifthrs = third + first;
int sixthrs = third + second;
int seventhrs = fourth + first;
int eightrs = fourth + second;
int firstresult = first + third + fourth;
int secondresult = first + fourth + third;
int thirdresult = second + third + fourth;
int fourthrresult = second + fourth + third;
int fifthresult = third + first + second;
int sixthresult = third + second + first;
int seventhresult = fourth + first + second;
int eightresult = fourth + second + first;
if (firstrs == eightrs) // 1 + 3 == 4 + 2
{
Console.WriteLine("Yes");
Console.WriteLine(firstrs);
}
else if (secondrs == thirdrs) // 1 + 4 == 2 + 3
{
Console.WriteLine("Yes");
Console.WriteLine(secondrs);
}
else if (thirdrs == seventhrs) // 2 + 3 == 4 + 1
{
Console.WriteLine("Yes");
Console.WriteLine(thirdrs);
}
else if (fourthrs == fifthrs) // 2 + 4 == 3 + 1
{
Console.WriteLine("Yes");
Console.WriteLine(fourthrs);
}
else if (firstrs == fourthrs) // 3 + 1 == 2 + 4
{
Console.WriteLine("Yes");
Console.WriteLine(firstrs);
}
else if (sixthrs == secondrs) // 3 + 2 == 1 + 4
{
Console.WriteLine("Yes");
Console.WriteLine(sixthrs);
}
else if (seventhrs == thirdrs) // 4 + 1 == 2 + 3
{
Console.WriteLine("Yes");
Console.WriteLine(seventhrs);
}
else if (eightrs == firstrs) // 4 + 2 == 1 + 3
{
Console.WriteLine("Yes");
Console.WriteLine(eightrs);
} //
else if (firstresult == second) // 1 + 3 + 4 == 2
{
Console.WriteLine("Yes");
Console.WriteLine(firstresult);
}
else if (thirdresult == first) // 2 + 3 + 4 == 1
{
Console.WriteLine("Yes");
Console.WriteLine(thirdresult);
}
else if (fifthresult == fourth) // 3 + 1 + 2 == 4
{
Console.WriteLine("Yes");
Console.WriteLine(fifthresult);
}
else if (seventhresult == third) // 4 + 1 + 2 == 3
{
Console.WriteLine("Yes");
Console.WriteLine(seventhresult);
}
else
{
Console.WriteLine("No");
}
}
}