Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("combinari.in");
- ofstream fout("combinari.out");
- const short NMAX=20;
- int top,st[NMAX],n,k;
- void BACK(int top)
- {
- if(top==(k+1))
- {
- for(int i=1;i<=k;i++)
- fout<<st[i]<<" ";
- fout<<"\n";
- }
- else for(int i=1+st[top-1];i<=n;i++)
- {
- st[top]=i;
- BACK(top+1);
- }
- }
- int main()
- {
- fin>>n>>k;
- BACK(1);
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment