Advertisement
a53

PartitiiMultime2

a53
Dec 1st, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. short int x[12], n;
  5. ifstream fin("partitiimultime2.in");
  6. class OutParser
  7. {
  8. private:
  9. FILE *fout;
  10. char *buff;
  11. int sp;
  12.  
  13. void write_ch(char ch)
  14. {
  15. if(sp==50000)
  16. {
  17. fwrite(buff,1,50000,fout);
  18. sp=0;
  19. buff[sp++]=ch;
  20. }
  21. else
  22. {
  23. buff[sp++]=ch;
  24. }
  25. }
  26.  
  27. public:
  28. OutParser(const char* name)
  29. {
  30. fout=fopen(name,"w");
  31. buff=new char[50000]();
  32. sp=0;
  33. }
  34. ~OutParser()
  35. {
  36. fwrite(buff,1,sp,fout);
  37. fclose(fout);
  38. }
  39.  
  40. OutParser& operator <<(int vu32)
  41. {
  42. if(vu32<=9)
  43. {
  44. write_ch(vu32+'0');
  45. }
  46. else
  47. {
  48. (*this) <<(vu32/10);
  49. write_ch(vu32%10+'0');
  50. }
  51. return *this;
  52. }
  53.  
  54. OutParser& operator <<(long long vu64)
  55. {
  56. if(vu64<=9)
  57. {
  58. write_ch(vu64+'0');
  59. }
  60. else
  61. {
  62. (*this) <<(vu64/10);
  63. write_ch(vu64%10+'0');
  64. }
  65. return *this;
  66. }
  67.  
  68. OutParser& operator <<(char ch)
  69. {
  70. write_ch(ch);
  71. return *this;
  72. }
  73. OutParser& operator <<(const char *ch)
  74. {
  75. while(*ch)
  76. {
  77. write_ch(*ch);
  78. ++ch;
  79. }
  80. return *this;
  81. }
  82. };
  83. OutParser fout("partitiimultime2.out");
  84. short int maxim(short int k);
  85. void scrie();
  86. void Back(short int k);
  87. int main()
  88. {
  89. fin>>n;
  90. x[1]=1;
  91. Back(2);
  92. return 0;
  93. }
  94.  
  95. short int maxim(short int k)
  96. {
  97. short int i,z=0;
  98. for(i=1; i<k; i++)
  99. z=max(x[i],z);
  100. return z;
  101. }
  102. void scrie()
  103. {
  104. short int i,z,j;
  105. z=maxim(n+1);
  106. for(i=1; i<=z; i++)
  107. {
  108. for(j=1; j<=n; j++)
  109. if(x[j]==i)
  110. fout<<j;
  111. fout<<"*";
  112. }
  113. fout<<'\n';
  114. }
  115.  
  116. void Back(short int k)
  117. {
  118. if(k==n+1)
  119. scrie();
  120. else
  121. for(short int i=1; i<=maxim(k)+1; i++)
  122. {
  123. x[k]=i;
  124. Back(k+1);
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement