CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//Uses combination function from this link:
//https://www.tutorialspoint.com/cplusplus-program-to-generate-all-possible-combinations-out-of-a-b-c-d-e
#include<iostream>
#include <map>
using namespace std;
void Combi(multimap<int,int> Map, int reqLen, int s, int currLen, bool check[], int l)
{
if(currLen > reqLen)
return;
else if (currLen == reqLen) {
int i=0;
for (multimap<int,int>::iterator p = Map.begin(); p!=Map.end(); ++p)
{
if (check[i] == true)
{
cout << "(" << p->first << "," << p->second << ") ";
}
i++;
}
cout<<"\n";
return;
}
if (s == l) {
return;
}
check[s] = true;
Combi(Map, reqLen, s + 1, currLen + 1, check, l);
check[s] = false;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run