SHARE
TWEET

graf partial

a guest Nov 18th, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. void Read(int &n, int a[][100], char fisier[])
  8. {
  9.     int m;
  10.     char nume[256];
  11.     strcpy(nume, fisier);
  12.     strcat(nume, ".in");
  13.     ifstream fin(nume);
  14.     fin>>n;
  15.     fin>>m;
  16.     for(int i=1; i<=m; i++)
  17.     {
  18.         int x,y;
  19.         fin>>x>>y;
  20.         a[x][y]=1;
  21.         a[y][x]=1;
  22.     }
  23.     fin.close();
  24. }
  25.  
  26. int Verif(int a[][100], int b[][100], int n)
  27. {
  28.     for(int i=1; i<=n; i++)
  29.         for(int j=1; j<=n; j++)
  30.             if(a[i][j]==0 && b[i][j]==1)
  31.                 return 0;
  32.     return 1;
  33. }
  34.  
  35. int main()
  36. {
  37.     int a[100][100]={0}, b[100][100]={0}, n;
  38.     Read(n,a,"primul");
  39.     Read(n,b,"doi");
  40.     if(Verif(a,b,n))
  41.         cout<<"Graful al doilea este graf partial al primului.";
  42.     if(Verif(b,a,n))
  43.         cout<<"Primul graf este graf partial al grafului al doilea.";
  44.     return 0;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top