- 博客(15)
- 收藏
- 关注
原创 输入一个字符串,求字符的所有排列
#include #include #include using namespace std; void ComStr(char *str, string &s,int m) { if (m == 0) { cout<<s<<endl; return ; } if (*str != '\0') { s.push_back(*str); ComStr(str+1,s
2014-08-12 16:07:01 646
原创 输入一个数组,判断该数组是否是某二叉树的前序遍历结果
#include using namespace std; bool verify_tree_pre(int a[],int len) { if (a==NULL || len<=0) { return false; } int root = a[0]; int i,j; for (i=1;i<len;i++) { if (a[i] > root) { break
2014-08-11 21:20:48 759
原创 用循环的方法实现二叉树的镜像
程序中包含了递归方法 和循环方法#include #include using namespace std; struct tree { int value; tree *left; tree *right; }; tree *create() { int n; cin>>n; if (n == 0) { return NULL; } else { tree *ro
2014-08-11 16:19:33 1913
原创 旋转数组的最小数字
自己补充的整个程序,包括排序,旋转,查找#include using namespace std; void my_sort(int a[],int len) { int temp; for (int i=0;i<len-1;i++) { for (int j=0;j<len-1-i;j++) { if (a[j]>a[j+1]) { temp = a[j];
2014-08-09 09:49:27 554
转载 快速排序
#include using namespace std; void Qsort(int a[],int low,int high) { if (low>=high) { return; } int first = low; int last = high; int key = a[first]; while (first { while (first=key) {
2014-08-08 21:31:28 520 1
原创 输入某二叉树的前序和中序遍历结果,重建该二叉树
/* 输入某二叉树的前序和中序遍历结果,重建该二叉树 */ #include using namespace std; struct tree { int value; tree *left; tree *right; }; tree *constructCore(int *s1,int *e1,int *s2,int *e2) { tree *root = n
2014-08-08 17:38:44 449
原创 有两个排序数组A1和A2,内存在A1的末尾有足够多的空余空间容纳A2,实现一个函数,把A2 插入到A1,并且是有序的。
/* 有两个排序数组A1和A2,内存在A1的末尾有足够多的空余空间容纳A2,实现一个函数,把A2 插入到A1,并且是有序的。 */ #include using namespace std; void fun(int a[],int len1,int b[],int len2) { int i = len1+len2; i--; len1--; len2--; while
2014-08-08 16:02:22 3716 1
原创 请实现一个函数,把字符串中的每个空格替换成“ ”
#include #include using namespace std; void fun(char string[],int len) { if(string == NULL && len return ; int count = 0; int i = 0; while (string[i]!='\0') { if (string[i] == ' ') { c
2014-08-08 15:36:37 826
原创 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数
/*在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 */ #include using namespace std; bool myFind(int a[][4],int rows,int columns,int value) { int row = 0; i
2014-08-08 11:41:42 2524
原创 大数相除
#include #include using namespace std; int num1[210]={0}; int num2[210]={0}; int ff(int num1[],int num2[],int len1,int len2) { if(len1 { return -1; } if(len1==len2) { for(int i=len1-1;i
2014-08-06 20:39:40 595
原创 将w字符串中m个字符移动到字符串的前边,其余依次向右移动
/* 将w字符串中m个字符移动到字符串的前边,其余依次向右移动 */ #include #include using namespace std; void fun(char *w , int m) { char p[10]; strcpy(p,w); int len = strlen(w); if (m>len) { m = len; } for (int i=
2014-08-04 14:51:07 913
原创 转换字符串格式为原来字符串里的字符+该字符连续出现的个数
/* 转换字符串格式为原来字符串里的字符+该字符连续出现的个数 */ #include #include using namespace std; int main() { string s; cin>>s; for (int i=0;i { int count = 1; int k = i; while(s[i+1]) { if (s[i+1]==s[k])
2014-08-04 12:00:26 563
原创 将一句话里的单词进行倒置
/* 将一句话里的单词进行倒置,标点符号不倒换。比如:i come from yantai.倒换后变为 yantai. from come i */ #include #include using namespace std; int main() { char str[100]; gets(str); int len = strlen(str); int i,j; c
2014-08-04 11:30:51 899
原创 strstr()函数
/* 写函数strstr(),不要使用任何C中已有的函数 */ #include using namespace std; const char* strstr(const char *string,const char *strCharSet) { for (int i=0;string[i]!='\0';i++) { int j; int k = i; for (j=0
2014-08-04 11:00:04 436
原创 单词迷宫
//Word Maze(单词迷宫) //Word?Maze?是一个网络小游戏,你需要找到以字母标注的食物,但要求以给定单词字母的顺序吃掉。如上图,假设给定单词if,你必须先吃掉i然后才能吃掉f。 //????但现在你的任务可没有这么简单,你现在处于一个迷宫Maze(n×m的矩阵)当中,里面到处都是以字母标注的食物,但你只能吃掉能连成给定单词W的食物。 //如下图,指定W为“SOLO”,则在地
2014-08-04 10:12:54 1491
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人