Не все ветви кода возвращают значение - C# (184308)
Формулировка задачи:
using System;
using System.Linq;
using System.Text;
namespace RockPaperScissors
{
class Program
{
public static void Main()
{
Console.WriteLine(MiddleOf(5, 0, 100)); // => 5
Console.WriteLine(MiddleOf(12, 12, 11)); // => 12
Console.WriteLine(MiddleOf(2, 3, 2));
Console.WriteLine(MiddleOf(8, 8, 8));
Console.WriteLine(MiddleOf(5, 0, 1));
}
public static int MiddleOf(int a, int b, int c)
{
if (a > b)
if (b > c) return b;
else if (a > c) return a;
if (b > c)
if (c > b) return c;
if (b > c) return b;
else if (c > b)
return c;
}
}
}Решение задачи: «Не все ветви кода возвращают значение»
textual
Листинг программы
public static int MiddleOf(int a, int b, int c)
{
if (a <= b && a >= c || a >= b && a <= c) return a;
if (b <= a && b >= c || b >= a && b <= c) return b;
else return c;
}