Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n[] = {1, 2, 3 , 4, 5}, nr = 0;
- void munte(int k, int p = 0) {
- if (k == 5) {
- cout << n[0] << n[1] << n[2] << n[3] << n[4] << n[3] << n[2] << n[1] << n[0] << ' ';
- nr++;
- return;
- }
- for (int i = p + 1; i <= 9; i++) {
- n[k] = i;
- munte(k + 1, i);
- }
- }
- int main() {
- munte(0);
- cout << '\n' << nr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment