_在路上

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年10月4日

摘要: #include <stdio.h>/************************************************************************//* 汉诺塔: 将n个盘从one座借助two座,移到three座 *//************************************************************************/void hanoi_Example (void){ int m; printf("input the number of di... 阅读全文
posted @ 2012-10-04 21:12 _在路上 阅读(231) 评论(7) 推荐(0) 编辑

摘要: 该题目摘自《C专家编程》附录A.4 编程挑战。#include <stdio.h>//检查该点有效返回1,否则返回0int CheckPosition (int (*chess)[8], int row, int col){ int IsTrue = 1; int i, j; //左上方,行数减,列数减 for (i = row, j = col; IsTrue && i >= 0 && j >= 0; i--, j--) { if (chess[i][j] == 1) IsTrue = 0; } //上方,列数不... 阅读全文
posted @ 2012-10-04 21:04 _在路上 阅读(188) 评论(0) 推荐(0) 编辑

摘要: 该题目摘自《C专家编程》附录A.4 编程挑战。#include <stdio.h>#include <stdlib.h>#include <string.h>void DisOneStr (const char * str, int k, int n){ int i, j; char * buf; if (k <= 0 || n <= 0 || k > n) return ; if (k == 1) { for (i = 0; i < n; i++) printf("%c\r\n", str[i]); ... 阅读全文
posted @ 2012-10-04 20:57 _在路上 阅读(408) 评论(2) 推荐(0) 编辑

摘要: #include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#define TRUE 1#define FALSE 0//筛选法非优化版本void CalPrime (int n){ int i, j, k; int * arr; if (n < 2) return ; arr = (int *)malloc(sizeof(int) * (n+1)); memset(arr, TRUE, sizeof(int) * (n+1)); ar... 阅读全文
posted @ 2012-10-04 20:28 _在路上 阅读(369) 评论(0) 推荐(0) 编辑