Advertisement
uchihamadara3

grafuri 4/175

Jan 15th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("graf1.in");
  6. ifstream fin1("graf2.in");
  7. ofstream fout("reuniune.out");
  8. ofstream fout1("intersectie.out");
  9.  
  10. /// 4/175 manulal
  11.  
  12. int n;
  13. int a[101][101], b[101][101];
  14. int I[101][101], R[101][101];
  15.  
  16. int main()
  17. {
  18.     int n, x, y;
  19.     fin>>n;
  20.     while(fin>>x>>y) a[x][y] = a[y][x] = 1;
  21.     fin>>n;
  22.     while(fin1>>x>>y) b[x][y] = b[y][x] = 1;
  23.  
  24.     for(int i=1;i<=n;++i, fout<<'\n', fout1<<'\n')
  25.         for(int j=1;j<=n;++j)
  26.             fout1<<(I[i][j] = a[i][j] & b[i][j])<<' ',
  27.             fout <<(R[i][j] = a[i][j] | b[i][j])<<' ';
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement