Hamilton - Code C++

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Hamilton - Code C++ as PDF for free.

More details

  • Words: 275
  • Pages: 2
// 0812016.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "conio.h" #define MAX 100 struct graph { int n; int L[MAX][MAX]; }; typedef struct graph GRAPH; GRAPH g; int chuaxet[MAX]; int hamilton[MAX+1]; int soct, sodd; int DocFile(char *s); void CTHamilton(int lan); void DDHamilton(int lan); void InHamilton(int n); void main() { if(!DocFile("input.txt")) return; for(int i=0; i
perror("Cannot open file"); return 0;

} fscanf(f, "%d", &g.n); for(int i=0; i 0) { soct++; hamilton[lan] = 0; printf("Chu trinh Hamilton thu %d: ", soct); InHamilton(g.n+1); } else if(lan < g.n) for(int y=0; y 0 && chuaxet[y]) { hamilton[lan] = y; chuaxet[y] = 0; CTHamilton(lan+1); chuaxet[y] = 1; } } void DDHamilton(int lan) { if(lan == g.n) { sodd++; printf("Duong di Hamilton thu %d: ", sodd); InHamilton(g.n); } else if(lan < g.n) for(int y=0; y 0 && chuaxet[y]) { hamilton[lan] = y; chuaxet[y] = 0; DDHamilton(lan+1); chuaxet[y] = 1; } } void InHamilton(int n) { for(int i=0; i", hamilton[i]); printf("%d\n", hamilton[n-1]); }

Related Documents

Hamilton - Code C++
July 2020 1
Hamilton
October 2019 39
Hamilton
December 2019 33
Hamilton
October 2019 32
Gray Code In C
June 2020 2