Advertisement
apl-mhd

Bappy sir Online

Apr 4th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.       char vertex[26];
  8.  
  9.       int i, j,vertices,v1,v2,x;
  10.       char ch = 'A';
  11.       char v;
  12.       int graph[10][10] ={0};
  13.  
  14.  
  15.  
  16.       for(i=0; i<26; i++)
  17.         vertex[i]= ch++;
  18.  
  19.         cout<<"No of vertices";
  20.         cin>>vertices;
  21.  
  22.  
  23.  
  24.  
  25.  
  26.         for(i=0; i<vertices; i++){
  27.  
  28.             for(j=i+1; j<vertices; j++){
  29.  
  30.                 printf("%c %c:", vertex[i], vertex[j]);
  31.                     cin>>x;
  32.                     graph[i][j] =x;
  33.                     graph[j][i] =x;
  34.  
  35.             }
  36.         }
  37.  
  38.  
  39.          for(i=0; i<vertices; i++){
  40.  
  41.             printf("%c->", vertex[i]);
  42.  
  43.             for(j=0; j<vertices; j++){
  44.  
  45.                    if(graph[i][j] == 1)
  46.                 printf(" %c",vertex[j]);
  47.             }
  48.             cout<<endl;
  49.         }
  50.  
  51.     cout<<"input vertex";
  52.  
  53.       cin>>v;
  54.  
  55.         x = v - 65;
  56.  
  57.  
  58.         for(i=0; i<vertices; i++){
  59.  
  60.             if(graph[x][i] ==1){
  61.  
  62.                 cout<<vertex[i]<<" ";
  63.             }
  64.  
  65.         }
  66.  
  67.  
  68.  
  69.  
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement