Vla_DOS

Untitled

Jun 5th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include<conio.h>
  5. #include<cctype>
  6. #include <Windows.h>
  7. using namespace std;
  8.  
  9. void ShowAllCombinations(int* a, int n, int l)
  10. {
  11.     int j = 0;
  12.     for (int i = 0; i < l; i++)
  13.     {
  14.         for (j = 0; j < n; j++)
  15.             if (a[j] == i + 1) break;
  16.         if (j == n)
  17.         {
  18.             a[n] = i + 1;
  19.             if (n < l - 1)
  20.                 ShowAllCombinations(a, n + 1, l);
  21.             else
  22.             {
  23.                 for (int k = 0; k < l; k++)
  24.                     cout << (a[k]);
  25.                 cout << endl;
  26.             }
  27.         }
  28.     }
  29. }
  30. void main()
  31. {
  32.     setlocale(LC_ALL, "ukr");
  33.     cout <<"N = ";
  34.     int n = 0;
  35.     cin >> n;
  36.  
  37.     if (n <= 10)
  38.     {
  39.         int* a = new int[n];
  40.         for (int i = 0; i < n; i++)
  41.         {
  42.             a[i] = rand() % 12;
  43.         }
  44.         ShowAllCombinations(a, 0, n);
  45.     }
  46.     else
  47.     {
  48.         cout << "N повинно бути рівним або меньшим 10!";
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment