keymasterviriya1150

Code (Adjacency Mat.)

May 17th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     //Code (Adjacency Mat.)
  8.     int V,E;
  9.     cout << "Vertex :";
  10.     cin >> V  ;
  11.     cout <<endl<<"Edge :";
  12.     cin >> E;   //
  13.     int weight[V][V];
  14.     for(unsigned int e=0;e<E;e++)
  15.     {
  16.         int i,k,w;
  17.         cout << "i :";//Vertex  at i
  18.         cin >> i;
  19.        
  20.         cout << "k :"; // Vertex    at k     
  21.         cin >> k;
  22.        
  23.         cout << "w :";// weight
  24.         cin >> w;
  25.        
  26.         weight[i][k]=w;
  27.        
  28.      }
  29.      /* testcase  
  30.     5 10
  31.     0 0 2
  32.     0 1 3
  33.     0 2 1
  34.     1 3 3
  35.     2 0 3
  36.     2 1 2
  37.     2 4 2
  38.     3 2 1
  39.     3 4 1
  40.     4 1 1
  41.     */
  42. }
Advertisement
Add Comment
Please, Sign In to add comment