using System; using System.Collections.Generic; using System.Text; namespace kino { class Program { static bool[] fronta; static void generuj(int clovek, int zasoba, int pocet1, int pocet2) { int i; if (pocet1 + pocet2 == 0) { for (i = 0; i < clovek; i++) { if (fronta[i]) Console.Write('1'); else Console.Write('2'); } Console.WriteLine(); } if (pocet1 > 0) { fronta[clovek] = true; generuj(clovek + 1, zasoba + 1, pocet1 - 1, pocet2); } if (pocet2 > 0 && zasoba > 0) { fronta[clovek] = false; generuj(clovek + 1, zasoba - 1, pocet1, pocet2 - 1); } } static void Main(string[] args) { int n; Console.WriteLine("Pocet lidi = 2*n."); Console.Write("n = "); n = Convert.ToInt32(Console.ReadLine()); fronta = new bool[2 * n + 2]; generuj(0, 0, n, n); } } }