|
|
back to boardC# Runtime error Posted by Serge 14 Jan 2018 20:22 //Please, help. Why "Runtime error" ? using System; namespace ConsoleApp33 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] v = new int[n]; string[] b = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i<v.Length; i++) { v[i] = int.Parse(b[i]); } Array.Sort(v); Array.Reverse(v); int k1 = v[0]; int k2 = v[1]; for (int i = 2; i<v.Length; i++) { if (k1 >= k2) { k2 += v[i]; } else { k1 += v[i]; } } int x; if (k1 >= k2) { x = k1 - k2; } else { x = k2 - k1; } Console.WriteLine(x); //Console.ReadKey(); } } } |
|
|