Guest User

claudiu

a guest
Oct 23rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <fstream>
  2. //#include <iostream>
  3. using namespace std;
  4. ifstream cin("partitiimultime.in");
  5. ofstream cout("partitiimultime.out");
  6. int n,sol[32],maxim[32];
  7. void back(int k);
  8. int main()
  9. {
  10. cin>>n;
  11. sol[1]=maxim[1]=1;
  12. back(2);
  13. return 0;
  14. }
  15. void back(int k)
  16. {
  17. if(k==n+1)
  18. {
  19. for(int i=1; i<=n; i++)
  20. {
  21. bool boi=false;
  22. for(int j=1; j<=n; j++)
  23. if(sol[j]==i)
  24. cout<<j, boi=true;
  25. if(boi)
  26. cout<<'*';
  27. }
  28. cout<<'\n';
  29. }
  30. else
  31. {
  32. for(int i=1; i<=maxim[k]+1; i++)
  33. {
  34. sol[k]=i;
  35. maxim[k]=max(maxim[k-1],i);
  36. back(k+1);
  37. maxim[k]=maxim[k-1];
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment