Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static public void BornCode(int n, int r, string[] ArrayOfWords, out int[,] Matrix)
- {
- Func<int, int> f = null;
- f = x => x > 1 ? x * f(x - 1) : 1;
- Matrix = new int[n - 1, f(n) / f(n - r)];
- int flag1 = 0, flag2 = 0;
- for (int i = 1; i <= n - 1; i++)
- {
- for (int l = 0; l <= (f(n)/f(n - r) * f(r)) - 1; l++)
- {
- //charArray = ArrayOfWords[l].ToCharArray(l - 1, r);
- for (int j = 0; j <= (r - 1) - 1; j++)
- {
- if (Convert.ToByte(ArrayOfWords[l][j]) == i) flag1 = 1;
- if (Convert.ToByte(ArrayOfWords[l][j]) == i + 1) flag2 = 1;
- }
- if (flag1 == flag2)
- {
- Matrix[i, l] = 0; Console.Write(Matrix[i, l]);
- }
- if (flag1 > flag2)
- {
- Matrix[i, l] = 1; Console.Write(Matrix[i, l]);
- }
- if (flag1 < flag2)
- {
- Matrix[i, l] = -1; Console.Write(Matrix[i, l]);
- }
- flag1 = 0;
- flag2 = 0;
- }
- Console.WriteLine();
- }
- }
- static void Main(string[] args)
- {
- Func<int, int> f = null;
- f = x => x > 1 ? x * f(x - 1) : 1;
- int n = 0, r = 0;
- n = Convert.ToInt32(Console.ReadLine());
- r = Convert.ToInt32(Console.ReadLine());
- int[,] Matrix = new int[n - 1, f(n) / f(n - r)];
- string[] ArrayOfWords = new string[] {"12", "13", "14", "23", "24", "34"};
- BornCode(n, r, ArrayOfWords, out Matrix);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement