UVa 291 - The House Of Santa Claus
2012-11-14 13:20
309 查看
题目:欧拉回路。
分析:简单题、搜索。
分析:简单题、搜索。
#include <stdio.h> #include <stdlib.h> #include <string.h> int G[6][6] = {0}; int save[9]; void dfs( int s, int n, int d, int e ) { if ( d == e ) { for ( int i = 0 ; i < e ; ++ i ) printf("%d",save[i]); printf("%d\n",s); return; } save[d] = s; for ( int i = 1 ; i <= n ; ++ i ) if ( G[s][i] ) { G[s][i] = 0; G[i][s] = 0; dfs( i, n, d+1, e ); G[s][i] = 1; G[i][s] = 1; } } int main() { G[1][2] = G[2][1] = 1; G[1][3] = G[3][1] = 1; G[1][5] = G[5][1] = 1; G[2][3] = G[3][2] = 1; G[2][5] = G[5][2] = 1; G[3][4] = G[4][3] = 1; G[3][5] = G[5][3] = 1; G[4][5] = G[5][4] = 1; dfs( 1, 5, 0, 8 ); return 0; }
相关文章推荐
- UVA 291 The House Of Santa Claus (DFS求一笔画)
- UVA 291 The House Of Santa Claus(DFS/深搜)
- UVA 291 The House Of Santa Claus(DFS算法)
- UVA 291 The House Of Santa Claus(DFS算法)
- UVA 291 The House Of Santa Claus 解题报告
- UVA 291 The House Of Santa Claus 图的遍历
- (DFS11.2.1)UVA 291 The House Of Santa Claus(使用DFS来解决一笔画问题)
- uva 291 The House Of Santa Claus
- 291 - The House Of Santa Claus
- 291 - The House Of Santa Claus
- The House Of Santa Claus(dfs)
- The House Of Santa Claus
- The House Of Santa Claus
- UVA291_The House Of Santa Claus(DFS)
- (深度搜索)The House Of Santa Claus
- uva 539 - The Settlers of Catan
- UVa 11292 The Dragon of Loowater 【贪心】
- UVa 10499 - The Land of Justice
- UVa 437 - The Tower of Babylon LIS
- UVA 437 - The Tower of Babylon(DAG最长路)