Sunteți pe pagina 1din 1

Distanta cea mai scurta dintre 2 puncte if(a[x[k-1]][x[k]]==0) return 0;

else
#include <iostream>
for(int i=0;i<k;i++)
#include <cstdlib>
if(x[k]==x[i]) return 0;
using namespace std;
return 1;
int a[6][6]=
}
{
int main()
{0, 0, 0, 0, 0, 0},
{
{0, 0, 10,50,30, 0},
int k;
{0, 10, 0,20, 0, 0},
cout<<"nod initial: "; cin>>A;
{0, 50,20, 0, 0, 10},
cout<<"nod final: "; cin>>B;
{0, 30, 0, 0, 0, 20},
x[0]=A;
{0, 0, 0, 10,20, 0},
k=1;
while(k)
},n=5,x[20],A,B,Min=9999;
{
void afisare(int k)
x[k]++;
{
if(x[k]>n) k--;
int s=0,i;
else if(cond(k))
for(i=1;i<=k;i++) s+=a[x[i-1]][x[i]];
if(x[k]==B) afisare(k);
if(s<Min){
else x[++k]=0;
system("CLS");
for(int i=0;i<=k;i++) cout<<x[i]<<" ";
cout<<endl; Min=s;}
}
}
return 0;
int cond(int k)
}
{