Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- fstream f("graf.in");
- int a[101][101],n,m,viz[31],L[31],C[31],x,y,k;
- void citire()
- {
- int b,c;
- while(f>>b>>c)
- {
- a[b][c]=a[c][b]=1;
- }
- f.close();
- }
- void lant_x_y(int z,int pas)
- {
- int i,j;
- if(x=y)
- {
- for(j=1; j<pas; j++)
- cout<<L[j]<<" ";
- cout<<endl;
- }
- else
- for(i=1; i<=n; i++)
- {
- if(a [z][i]&&!viz[i])
- {
- L[pas]=i;
- viz[i]=1;
- lant_x_y(i,pas+1);
- viz[i]=0;
- }
- }
- }
- int main()
- {
- citire();
- cin>>x>>y;
- viz[x]=1;
- L[1]=x;
- lant_x_y(x,2);
- viz[x]=0;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement