Advertisement
Guest User

Stuck Numbers

a guest
Jul 16th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class StuckNumbers
  5. {
  6.     static void Main()
  7.     {
  8.         int n = int.Parse(Console.ReadLine());
  9.         string[] input = Console.ReadLine().Split(' ').ToArray();
  10.         //int[] numbers = new int[n];
  11.         //for (int i = 0; i < numbers.Length; i++)
  12.         //{
  13.         //    numbers[i] = int.Parse(input[i]);
  14.         //}
  15.         bool isPrint = false;
  16.         for (int a = 0; a < n; a++)
  17.         {
  18.             for (int b = 0; b < n; b++)
  19.             {
  20.                 for (int c = 0; c < n; c++)
  21.                 {
  22.                     for (int d = 0; d < n; d++)
  23.                     {
  24.                         if (a != b && a != c && a != d &&
  25.                             b != c && b != d && c != d)
  26.                         {
  27.                             string first = input[a] + input[b];
  28.                             string second = input[c] + input[d];
  29.                             if (first == second)
  30.                             {
  31.                                 Console.WriteLine("{0}|{1}=={2}|{3}", input[a], input[b], input[c], input[d]);
  32.                                 isPrint = true;
  33.                             }
  34.                         }
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.         if (isPrint == false)
  40.         {
  41.             Console.WriteLine("No");
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement