Advertisement
icatalin

graf conexe parcurgere latime

Feb 29th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int n,a[100][100];
  7. int viz [1000],n,conexe;
  8.  
  9. int cuata()
  10. {
  11.     int i;
  12.     for (i=1;i<=n;i++)
  13.         if (viz[i]==0)
  14.         return i;
  15.     return =1;
  16. }
  17.  
  18. int bf(int x)
  19. {
  20.     //parcurgerea in latime
  21. }
  22.  
  23.  
  24. void citire()
  25. {
  26.     //...
  27. }
  28.  
  29. int nr_comp()
  30. {
  31.     int x;
  32.    
  33.     do
  34.     {
  35.         x=cauta();
  36.         if (x!=-1)
  37.         {
  38.             conexe+1;
  39.             bf(x);
  40.         }
  41.     }while (x!=-1);
  42.    
  43.     return conexe;
  44. }
  45.  
  46. int main()
  47. {
  48.     citire();
  49.     cout<<nr_comp();
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement