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