Advertisement
amrin26

Graph 4

Feb 17th, 2020
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3.  using namespace std;
  4.  
  5.  int main()
  6.  {
  7.      int ne;
  8.      cin>>ne;
  9.      int adj[ne+1][ne+1];
  10.  
  11.      for(int r=0;r<=8;r++)
  12.      {
  13.               for(int c=0;c<=8;c++)
  14.               {
  15.                   adj[r][c] = INT_MAX;
  16.               }
  17.  
  18.      }
  19.  
  20.      for(int i=1; i<=ne; i++)
  21.      {
  22.          int u,v,w;
  23.          cin>>u>>v>>w;
  24.          adj[u][v]=w;
  25.          adj[v][u]=w;
  26.      }
  27.  
  28.        for(int r=0;r<=8;r++)
  29.      {
  30.               for(int c=0;c<=8;c++)
  31.               {
  32.                   if(adj[r][c]==INT_MAX)
  33.                     cout<<"NULL " ;
  34.                   else
  35.                   cout<<adj[r][c] <<"   ";
  36.               }
  37.               cout<<endl;
  38.  
  39.      }
  40.      return 0;
  41.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement