main.c

来自「蚁群算法C程序」· C语言 代码 · 共 37 行

C
37
字号
/*
      ANT-CYCLE ALGORITHM FOR TSP
      File:    main.c
      Purpose: main function
     */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "acs.h"
#include "tsp.h"
#include "data_input.h"

FILE *f_out;

int main(void)
{
    double length;
    Point p[CITY_NUM+1];

	if ( (f_out = fopen("result.txt", "w+")) == NULL)
	{
		fprintf(stderr, "can not create file result.txt\n");
		exit(2);
	}

    read_data("Oliver30.tsp", p);
/*    print_coordinates(p); */
    caculate_distances(p);
/*	print_distance(); */

    printf("Now , try to find the best tour...\n");
    length = find_best_tour();
    printf("Shortest Tour Length is : %f\n", length);

    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?