- 博客(5)
- 收藏
- 关注
原创 给出一颗二叉搜索树,将它转换为有序的双向链表输出
中序遍历,创建出一个新的双向链表 #include #include int a[7] = {10,14,6,12,16,8,4}; class Node { public: Node(int dat=0):data(dat),left(0),right(0),parent(0) {} int data; Node* left; Node* right; Nod
2013-10-18 12:55:46
699
原创 字符串的四则运算
可以处理+-*/()的情况 #include #include #include #include using namespace std; const char sta[] = {'+','-','*','/','(',')'}; const int Priority[] = {1,1,2,2,3,0}; const int Priority1[] = {1,1,2,2,0,3
2013-10-18 12:53:19
343
原创 KMP
学习编程之KMP, 仅仅看别人的代码看再多也没有用,于是我决定自己学着写写看,哪怕效率低也无所谓,勇敢的踏出自己写代码的第一步 #include #include using namespace std; bool match(const char *a, int lb, int rb, int len) { int i=lb; int j=rb; int k; for(
2013-09-26 16:03:01
366
原创 输入一个字符串,打印出该字符串中字符的所有排列。
#include using namespace std; void swap(char *x,char *y) { char temp; temp = *x; *x = *y; *y = temp; } void perm(char *list,int i,int max) { int j,k; if(i>max) { for(i=0;i {
2013-09-22 09:34:28
801
原创 输入两个整数 n 和 m,从数列1,2,3.......n 中 随意取几个数,使其和等于 m ,要求将其中所有的可能组合列出来.
新手学习编程,简单的递归,把所有的分支都遍历到。细节的调试也稍微花了一点时间。 #include using namespace std; int *flag = NULL; int n,m; void PrintOut(int index) { int i; for(i=1;i { if(flag[i]) cout } cout } void B
2013-09-21 09:37:45
410
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅