|
|
вернуться в форумPlease help. Why wrong answer 1? (C#) Послано Arty 25 янв 2011 19:39 My programm: static void Main(string[] args) { int d = new int(); int n = new int(); int k = new int(); int k1= new int(); int k2 = new int(); do { Console.WriteLine("Kolichestvo N:"); n = Convert.ToInt32(Console.ReadLine()); } while (n < 1 || n > 20); int[] q = new int[n]; Console.WriteLine("Vedite masiv:"); string[] str = Console.ReadLine().Split(new char[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < (n < str.Length ? n : str.Length); i++) { d = Convert.ToInt32(str[i]); if (d >= 1 & d <= 100000) q[i] = d; } Array.Sort(q); Array.Reverse(q); k1 = q[0]; k2 = q[1]; for (int i = 2; i <q.Length; i++) { if (k1 > k2) k2 = k2 + q[i]; else k1 = k1 + q[i]; } if (k1 > k2) k = k1 - k2; else k = k2 - k1; Console.WriteLine(k); Re: Please help. Why wrong answer 1? (C#) Maybe because you write text before typing =) Re: Please help. Why wrong answer 1? (C#) Послано daco 11 мар 2011 02:04 Read FAQ. |
|
|