Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- short int x[12], n;
- ifstream fin("partitiimultime2.in");
- class OutParser
- {
- private:
- FILE *fout;
- char *buff;
- int sp;
- void write_ch(char ch)
- {
- if(sp==50000)
- {
- fwrite(buff,1,50000,fout);
- sp=0;
- buff[sp++]=ch;
- }
- else
- {
- buff[sp++]=ch;
- }
- }
- public:
- OutParser(const char* name)
- {
- fout=fopen(name,"w");
- buff=new char[50000]();
- sp=0;
- }
- ~OutParser()
- {
- fwrite(buff,1,sp,fout);
- fclose(fout);
- }
- OutParser& operator <<(int vu32)
- {
- if(vu32<=9)
- {
- write_ch(vu32+'0');
- }
- else
- {
- (*this) <<(vu32/10);
- write_ch(vu32%10+'0');
- }
- return *this;
- }
- OutParser& operator <<(long long vu64)
- {
- if(vu64<=9)
- {
- write_ch(vu64+'0');
- }
- else
- {
- (*this) <<(vu64/10);
- write_ch(vu64%10+'0');
- }
- return *this;
- }
- OutParser& operator <<(char ch)
- {
- write_ch(ch);
- return *this;
- }
- OutParser& operator <<(const char *ch)
- {
- while(*ch)
- {
- write_ch(*ch);
- ++ch;
- }
- return *this;
- }
- };
- OutParser fout("partitiimultime2.out");
- short int maxim(short int k);
- void scrie();
- void Back(short int k);
- int main()
- {
- fin>>n;
- x[1]=1;
- Back(2);
- return 0;
- }
- short int maxim(short int k)
- {
- short int i,z=0;
- for(i=1; i<k; i++)
- z=max(x[i],z);
- return z;
- }
- void scrie()
- {
- short int i,z,j;
- z=maxim(n+1);
- for(i=1; i<=z; i++)
- {
- for(j=1; j<=n; j++)
- if(x[j]==i)
- fout<<j;
- fout<<"*";
- }
- fout<<'\n';
- }
- void Back(short int k)
- {
- if(k==n+1)
- scrie();
- else
- for(short int i=1; i<=maxim(k)+1; i++)
- {
- x[k]=i;
- Back(k+1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement