Travelling Salesman Problem




SOURCE CODE

#include”iostream.h”
#include”conio.h”
int a[10][10],visited[10],cost=0,n,min1;
void mincost(int city);
int least(int c)
{
int i,nc=999,min=999;
for(i=1;i < =n;i++) { if((a[c][i]!=0)&&(visited[i]==0)) if(a[c][i] < min="a[i][0]+a[c][i];" nc="i;" min1="a[c][i];" cost="min1;"> ";
ncity=least(city);
if(ncity==999)
{
ncity=0;
cout < <> > n;
cout < < "Enter The Cost Matrix \n"; for(i=0;i < j="0;j"> > a[i][j];
visited[i]=0;
}
}
cout < < "\n\n Starting From The City: "; mincost(0); cout < < "\n Minimum Cost Is :\t " < <>