随笔分类 -  编程练习小程序

摘要:1: #include <stdio.h> 2: #include <math.h> 3: #include <stdlib.h> 4: #define STACK_INIT_SIZE 20 5: #define STACKINCREMENT 10 6: 7: typedef int ElemType; 8: typedef struct { 9: ElemT... 阅读全文
posted @ 2010-05-29 12:34 红脸书生 阅读(1334) 评论(1) 推荐(0)
摘要:使用动态栈结构 阅读全文
posted @ 2010-05-29 12:33 红脸书生 阅读(1827) 评论(0) 推荐(0)
摘要:1: #include "stdio.h" 2: 3: typedef struct BiTNode { 4: char data; /*结点的数据域*/ 5: struct BiTNode *lchild , *rchild; /*指向左孩子和右孩子*/ 6: } BiTNode , *BiTree; 7: 8: /*创建一棵二叉树*/ 9: void CreatBiTree(BiTree *... 阅读全文
posted @ 2010-05-29 12:06 红脸书生 阅读(1176) 评论(1) 推荐(1)
摘要:1: #include <stdio.h> 2: #include <stdlib.h> 3: 4: typedef struct node { 5: int data; 6: int freq; 7: struct node *prior; 8: struct node *next; 9: } dbLNode, *dbLinkList; 10: 11: /*创建一个双向... 阅读全文
posted @ 2010-05-29 11:57 红脸书生 阅读(1070) 评论(0) 推荐(0)
摘要:1: #include <stdio.h> 2: #include <stdlib.h> 3: #define STACK_INIT_SIZE 20 4: #define STACKINCREMENT 10 5: 6: typedef char ElemType; /*将char类型定义为ElemType*/ 7: typedef struct { /*定义一个栈类型*/ ... 阅读全文
posted @ 2010-05-29 11:46 红脸书生 阅读(599) 评论(0) 推荐(0)
摘要:1: #include <stdio.h> 2: #include <stdlib.h> 3: #define STACK_INIT_SIZE 20 4: #define STACKINCREMENT 10 5: 6: typedef char ElemType; /*将char类型定义为ElemType*/ 7: 8: typedef struct{ /*定义一个栈类型*... 阅读全文
posted @ 2010-05-28 10:27 红脸书生 阅读(997) 评论(0) 推荐(0)
摘要:同时使用一个栈和一个队列 阅读全文
posted @ 2010-05-28 10:14 红脸书生 阅读(1482) 评论(0) 推荐(0)
摘要:1: #include <stdio.h> 2: #include <math.h> 3: #include <stdlib.h> 4: #define STACK_INIT_SIZE 20 5: #define STACKINCREMENT 10 6: 7: typedef char ElemType; 8: typedef struct { 9: Elem... 阅读全文
posted @ 2010-05-28 10:11 红脸书生 阅读(1697) 评论(0) 推荐(0)
摘要:1: #include <stdio.h> 2: #include <stdlib.h> 3: 4: /*链表结点定义*/ 5: typedef struct node { 6: int number; /*编号*/ 7: int psw; /*个人密码*/ 8: struct node *next; 9: } LNode, *LinkList; 10: 11: 12:... 阅读全文
posted @ 2010-05-28 09:21 红脸书生 阅读(519) 评论(0) 推荐(0)
摘要:1: #include <stdio.h> 2: #include <stdlib.h> 3: 4: /*定义int为ElemType类型*/ 5: typedef int ElemType; 6: 7: /*定义链表的结点类型*/ 8: typedef struct node { 9: ElemType data; /*数据域*/ 10: struct node *ne... 阅读全文
posted @ 2010-05-28 09:09 红脸书生 阅读(448) 评论(0) 推荐(0)
摘要:1: /******************************************Dynamic Sort*************************************************/ 2: #include <string.h> 3: #include <stdio.h> 4: #include <malloc.h> 5: 6:... 阅读全文
posted @ 2010-05-28 09:02 红脸书生 阅读(454) 评论(0) 推荐(0)
摘要:利用原表的存储空间将顺序表(a1,a2,……,an)逆置为(an,an-1,………a1)。 阅读全文
posted @ 2010-05-28 08:55 红脸书生 阅读(3166) 评论(1) 推荐(1)
摘要:1: #include "stdio.h" 2: 3: struct player { 4: int num; 5: int score; 6: int rand; 7: } ; 8: 9: // 根据对选手的得分排序 10: void sortScore(struct player psn[], int n) 11: { 12: int i, j; 13: struct player ... 阅读全文
posted @ 2010-05-27 10:34 红脸书生 阅读(541) 评论(0) 推荐(0)
摘要:1: #include <stdio.h> 2: 3: void move(int n, char x, char y, char z) 4: { 5: if(n == 1) 6: printf("%c-->%c\n", x, z); 7: else 8: { 9: move(n - 1, x, z, y); 10: printf("%c-->%c\n", x, z); ... 阅读全文
posted @ 2010-05-27 10:25 红脸书生 阅读(541) 评论(0) 推荐(0)
摘要:1: #include "stdio.h" 2: 3: unsigned long myPow(int m, int n) 4: { 5: unsigned long tmp; 6: 7: if(n == 0) return 1; 8: 9: if(n == 1) return m; 10: 11: if(n % 2 == 0) { 12: tmp = myPow(m, n / 2); 13... 阅读全文
posted @ 2010-05-27 10:23 红脸书生 阅读(446) 评论(0) 推荐(0)
摘要:1: #include "stdio.h" 2: 3: int cnr(int m, int n) 4: { 5: if(m == n || n == 0) 6: return 1; 7: else 8: return cnr(m - 1, n) + cnr(m - 1, n - 1); 9: } 10: 11: int main() 12: { 13: int m, n; 14: pri... 阅读全文
posted @ 2010-05-27 10:20 红脸书生 阅读(331) 评论(0) 推荐(0)
摘要:递归分治二分查找法 阅读全文
posted @ 2010-05-27 10:15 红脸书生 阅读(756) 评论(0) 推荐(0)
摘要:A,B,C,D,E合伙抓鱼,全都睡着了。A第一个起来,将鱼分成5份,把多余的一条扔回河里,拿走自己一份走了。B第二个起来,又把鱼分成5份,把多余的一条扔回河里,拿走自己一份走了。接着,C,D,E都同样做。问渔夫们一共至少抓了多少条鱼? 阅读全文
posted @ 2010-05-27 10:01 红脸书生 阅读(644) 评论(0) 推荐(0)
摘要:1: #include "stdio.h" 2: 3: void Marx() 4: { 5: int x,y,z; 6: for(x=1;x<30;x++) 7: for(y=1;y<30;y++) 8: for(z=1;z<30;z++) 9: { 10: if(3*x+2*y+z==50 && x+y+z==30) 11: printf("%5d %5d... 阅读全文
posted @ 2010-05-27 09:56 红脸书生 阅读(690) 评论(0) 推荐(0)
摘要:找出11——999之间的所有三重回文数字,就是a的a,a平方,a立方都是回文 阅读全文
posted @ 2010-05-27 09:54 红脸书生 阅读(855) 评论(0) 推荐(0)