tanasaradu

Untitled

Dec 1st, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("gengraf.in");
  5. ofstream fout("gengraf.out");
  6. const int nmax=17;
  7. int a[nmax][nmax],n,st[nmax],top,x;
  8. inline void Formare()
  9. {
  10.  
  11. int x=1;
  12. for(int i=1;i<n;i++)
  13. for(int j=i+1;j<=n;j++)
  14. {
  15. a[i][j]=a[j][i]=x;
  16. x++;
  17. }
  18. }
  19. inline void Afisare()
  20. {
  21. for(int i=1;i<=n;i++)
  22. {
  23. for(int j=1;j<=n;j++)
  24. fout<<st[a[i][j]]<<" ";
  25. fout<<"\n";
  26. }
  27. fout<<"\n";
  28. }
  29. void Back(int top)
  30. {
  31. if(top==(x+1))
  32. Afisare();
  33. else for(int i=0;i<=1;i++)
  34. {
  35. st[top]=i;
  36. Back(top+1);
  37. }
  38. }
  39. int main()
  40. {
  41. fin>>n;
  42. x=(n*(n-1))/2;
  43. fout<<(1<<x)<<"\n";
  44. Formare();
  45. Back(1);
  46. fin.close();
  47. fout.close();
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment