Advertisement
Guest User

Untitled

a guest
May 19th, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. class StuckNumbers
  7. {
  8.     static void Main()
  9.     {
  10.         int n = int.Parse(Console.ReadLine());
  11.         List<string> numbers = Console.ReadLine().Split().ToList();
  12.         List<string> numbersTemp = numbers;
  13.         int count = 0;
  14.         if (n<4)
  15.         {
  16.             Console.WriteLine("No");
  17.             return;
  18.         }
  19.         foreach (string a in numbers)
  20.         {
  21.             numbersTemp = numbers.ToList();
  22.             numbersTemp.Remove(a);
  23.             foreach (string b in numbersTemp.ToList())
  24.             {
  25.                 numbersTemp.Remove(b);
  26.                 foreach (string c in numbersTemp.ToList())
  27.                 {
  28.                     numbersTemp.Remove(c);
  29.                     foreach (string d in numbersTemp)
  30.                     {
  31.                         if (a + b == c + d)
  32.                         {
  33.                             Console.WriteLine("{0}|{1}=={2}|{3}", a, b, c, d);
  34.                             count++;
  35.                         }
  36.                     }
  37.                     numbersTemp.Add(c);
  38.                 }
  39.                 numbersTemp.Add(b);
  40.             }
  41.             numbersTemp.Add(a);
  42.         }
  43.         if (count == 0)
  44.         {
  45.             Console.WriteLine("No");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement