Advertisement
Arden

Untitled

Jan 16th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static public void BornCode(int n, int r, string[] ArrayOfWords, out int[,] Matrix)
  12.         {
  13.             Func<int, int> f = null;
  14.             f = x => x > 1 ? x * f(x - 1) : 1;
  15.             Matrix = new int[n - 1, f(n) / f(n - r)];
  16.             int flag1 = 0, flag2 = 0;
  17.             for (int i = 1; i <= n - 1; i++)
  18.             {
  19.                 for (int l = 0; l <= (f(n)/f(n - r) * f(r)) - 1; l++)
  20.                 {
  21.                     //charArray = ArrayOfWords[l].ToCharArray(l - 1, r);
  22.                     for (int j = 0; j <= (r - 1) - 1; j++)
  23.                     {
  24.                         if (Convert.ToByte(ArrayOfWords[l][j]) == i) flag1 = 1;
  25.                         if (Convert.ToByte(ArrayOfWords[l][j]) == i + 1) flag2 = 1;
  26.                     }
  27.                     if (flag1 == flag2)
  28.                     {
  29.                         Matrix[i, l] = 0; Console.Write(Matrix[i, l]);
  30.                     }
  31.                     if (flag1 > flag2)
  32.                     {
  33.                         Matrix[i, l] = 1; Console.Write(Matrix[i, l]);
  34.                     }
  35.                     if (flag1 < flag2)
  36.                     {
  37.                         Matrix[i, l] = -1; Console.Write(Matrix[i, l]);
  38.                     }
  39.                     flag1 = 0;
  40.                     flag2 = 0;
  41.                 }
  42.                 Console.WriteLine();
  43.             }
  44.         }
  45.         static void Main(string[] args)
  46.         {
  47.             Func<int, int> f = null;
  48.             f = x => x > 1 ? x * f(x - 1) : 1;
  49.             int n = 0, r = 0;
  50.             n = Convert.ToInt32(Console.ReadLine());
  51.             r = Convert.ToInt32(Console.ReadLine());
  52.             int[,] Matrix  = new int[n - 1, f(n) / f(n - r)];
  53.             string[] ArrayOfWords = new string[] {"12", "13", "14", "23", "24", "34"};
  54.             BornCode(n, r, ArrayOfWords, out Matrix);
  55.             Console.ReadKey();
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement