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
| class Program { static void Main(string[] args) { int[] person = {0, 1, 1, 1, 1, 1, 15}; int needed = 0; int min = 0; int target = 0; for (int i = 1; i <= 6; i++) { needed = 0; for (int j = 1; j < i; j++) { needed += person[j] * (i - j); }
for (int j = i + 1; j <= 6; j++) { needed += person[j] * (j - i); }
if (min == 0 || min >= needed) { min = needed; target = i; } }
Console.WriteLine(target); Console.Read(); }
|