-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
47 lines (44 loc) · 883 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include"tsp.h"
int main(int argc ,char * argv[])
{ int i,j,n;
float total;
int k[2*SIZE];
FILE *source,*f3;
Element x[SIZE][SIZE];
f3 = fopen("check.txt","w");
char pgm[25];
printf("Enter the size ");
scanf("%d",&n);
strcpy(pgm,argv[1]);
source = fopen(pgm,"r");
if(source==NULL)
{
fprintf(stderr,"FILE %s not found\n",pgm);
return 1;
}
for(i=0;i<n;i++)
{ x[i][n+1].flag=0;
{ for(j=0;j<n;j++)
if(i!=j)
{ fscanf(source,"%f ",&x[i][j].e);
x[i][j].p=1.0;
x[i][j].flag=0;
}
else
{ x[i][j].e=MAX;
x[i][j].p=0.0001;
x[i][j].flag=1;
}
}
}
//operation(x,n);//
total = raco(x,n,k,900000);
printf("Optimal value = %f \n",total);
for(i=0;i<2*n;i=i+2)
printf(" %d,%d ",k[i]+1,k[i+1]+1);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
fprintf(f3," %f ",x[i][j].e) ;
fclose(f3);
return 0;
}