Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- //#include <iostream>
- using namespace std;
- ifstream cin("partitiimultime.in");
- ofstream cout("partitiimultime.out");
- int n,sol[32],maxim[32];
- void back(int k);
- int main()
- {
- cin>>n;
- sol[1]=maxim[1]=1;
- back(2);
- return 0;
- }
- void back(int k)
- {
- if(k==n+1)
- {
- for(int i=1; i<=n; i++)
- {
- bool boi=false;
- for(int j=1; j<=n; j++)
- if(sol[j]==i)
- cout<<j, boi=true;
- if(boi)
- cout<<'*';
- }
- cout<<'\n';
- }
- else
- {
- for(int i=1; i<=maxim[k]+1; i++)
- {
- sol[k]=i;
- maxim[k]=max(maxim[k-1],i);
- back(k+1);
- maxim[k]=maxim[k-1];
- }
- }
- }
Add Comment
Please, Sign In to add comment