Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include<conio.h>
- #include<cctype>
- #include <Windows.h>
- using namespace std;
- void ShowAllCombinations(int* a, int n, int l)
- {
- int j = 0;
- for (int i = 0; i < l; i++)
- {
- for (j = 0; j < n; j++)
- if (a[j] == i + 1) break;
- if (j == n)
- {
- a[n] = i + 1;
- if (n < l - 1)
- ShowAllCombinations(a, n + 1, l);
- else
- {
- for (int k = 0; k < l; k++)
- cout << (a[k]);
- cout << endl;
- }
- }
- }
- }
- void main()
- {
- setlocale(LC_ALL, "ukr");
- cout <<"N = ";
- int n = 0;
- cin >> n;
- if (n <= 10)
- {
- int* a = new int[n];
- for (int i = 0; i < n; i++)
- {
- a[i] = rand() % 12;
- }
- ShowAllCombinations(a, 0, n);
- }
- else
- {
- cout << "N повинно бути рівним або меньшим 10!";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment