SHARE
TWEET

Untitled

a guest May 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.    int a[20][20],n,xp,s[20],viz[20],urm[20],i,j,k,ps;
  6.    cout<<"Dati numarul de noduri:";cin>>n;
  7.    for(i=1;i<=n;i++)
  8.     for(j=1;j<=n;j++)
  9.     {
  10.         cout<<"a["<<i<<"]["<<j<<"]=";
  11.         cin>>a[i][j];
  12.     }
  13.     for(i=1;i<n;i++)
  14.     {
  15.         urm[i]=0;
  16.         viz[i]=0;
  17.     }
  18.     cout<<"Dati nodul de pornire:";cin>>xp;
  19.     viz[xp]=1;
  20.     s[1]=xp;
  21.     ps=1;
  22.     cout<<xp<<" ";
  23.     while(ps>=1)
  24.     {
  25.         j=s[ps];
  26.         k=urm[j]=k;
  27.         if(k==n+1);
  28.         while((k<=n&&a[j][k]==0)||(a[j][k]==1&&viz[k]==1))
  29.         k++;
  30.         urm[j]=1;
  31.         if(k==n+1)ps=ps-1;
  32.         else{
  33.             cout<<k<<" ";
  34.             viz[k]=1;
  35.             ps=ps+1;
  36.             s[ps]=k;
  37.         }
  38.     }
  39.     return 0;
  40.    }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top