Advertisement
apl-mhd

graph Input

Apr 3rd, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string.h>
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.  
  9.     int graph[5][5] = {0};
  10.  
  11.     int i,j;
  12.     int vertex, edg1, edg2,vertex1, vertex2;
  13.  
  14.  
  15.  
  16.  
  17.     for(i=0; i<4; i++){
  18.        cin>>vertex1>>vertex2;
  19.  
  20.        graph[vertex1][vertex2] = 1;
  21.         graph[vertex2][vertex1] = 1;
  22.     }
  23.  
  24.  
  25.     for(i=0; i<5; i++){
  26.  
  27.         cout<<i<<":";
  28.         for (j = 0;  j<5 ; j++) {
  29.  
  30.             if( graph[i][j] == 1)
  31.             cout<<j<<"->";
  32.         }
  33.         cout<<"NULL"<<endl;
  34.     }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement