Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. fstream f("graf.in");
  5. int a[101][101],n,m,viz[31],L[31],C[31],x,y,k;
  6.  
  7. void citire()
  8. {
  9. int b,c;
  10. while(f>>b>>c)
  11. {
  12. a[b][c]=a[c][b]=1;
  13. }
  14. f.close();
  15. }
  16. void lant_x_y(int z,int pas)
  17. {
  18. int i,j;
  19. if(x=y)
  20. {
  21. for(j=1; j<pas; j++)
  22. cout<<L[j]<<" ";
  23. cout<<endl;
  24. }
  25. else
  26. for(i=1; i<=n; i++)
  27. {
  28. if(a [z][i]&&!viz[i])
  29. {
  30. L[pas]=i;
  31. viz[i]=1;
  32. lant_x_y(i,pas+1);
  33. viz[i]=0;
  34. }
  35. }
  36. }
  37. int main()
  38. {
  39. citire();
  40. cin>>x>>y;
  41. viz[x]=1;
  42. L[1]=x;
  43. lant_x_y(x,2);
  44. viz[x]=0;
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement