自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 资源 (1)
  • 收藏
  • 关注

原创 两个链表一升一降,合并为一个升序链表。

#include using namespace std;class List {public: List(int num) { this->num = num; next = NULL; } int num; List* next;};//创建链表void createList(List* &list) { List* cur;

2013-03-30 20:07:14 1509

原创 判断二叉树是否平衡,计算树的高度

#include using namespace std;int count = 0;class BinTree{public: BinTree(int v){ value = v; left = NULL; right = NULL; } int value; BinTree* left; BinTree* right;};int max(int a,int b

2013-03-30 18:50:19 591

原创 一个数组下标从0到n,元素为从0到n的整数,判断其中是否有重复元素。

#include using namespace std;bool hasDuplicated(int* a,int len){ for(int i=0;i<len;i++){ if(a[i] == i) continue; if(a[i] == a[a[i]]) return true; swap(a[i],a[a[i]]); } return false;

2013-03-30 16:53:49 970

原创 汉诺塔

#include using namespace std;void move(char* a,char* b) { cout "<<b<<endl;}void hanoi(int n,char* a,char* b, char* c) { if(n == 1) { move(a,c); return; } hanoi(n-1,a,c,b); move(a,c); han

2013-03-30 14:11:22 340

原创 计算整形数中1的个数

#include using namespace std;int countOne(int n){    int count = 0;    while(n) {        if(n%10 == 1)             count ++;        n /= 10;    }    return count;}int main(){

2013-03-30 13:57:51 684

原创 实现strcmp函数

#include using namespace std;int strcmp(char* str1,char* str2){ while(*str1 != '\0' && *str2 != '\0' && *str1 == *str2){ str1++; str2++; } return *str1-*str2; }int main(){ char str1[

2013-03-30 13:49:01 617

原创 实现strstr函数

#include using namespace std;char* strstr(char* str1,char* str2,int len1,int len2){ for(int i = 0;i<len1;i++) { if(str1[i] == str2[0]){ for(int j=i+1,int k=1;j<len1 && k < len2;j++,k++) {

2013-03-30 13:34:53 400

原创 反转一个字符串

#include using namespace std;void swap(char *c1,char *c2){ char temp = *c1; *c1 = *c2; *c2 = temp;}void reverseString(char* str,int len){ for(int i=0;i<=len/2;i++) { swap(&str[i],&str[len-i-

2013-03-30 13:15:15 492

原创 判断链表是否有环

#include using namespace std;class List {public: List(int num) { this->num = num; } int num; List* next;};//创建链表List* createList(int count) { if(count == 0 ) return N

2013-03-30 13:08:42 393

原创 将字符串转换为长整形

#include using namespace std;long atol(char* num,int len) { long base = 1; long ret = 0; for(char* end = (char *)(num+len-1);end >= num;end --){ ret += (*end - '0') * base;

2013-03-29 20:41:55 1397

原创 字符串全排列,去除重复

#include using namespace std;void swap(char* s1,char* s2) { char temp = *s1; *s1=*s2; *s2=temp;}bool needSwap(char* str,int source,int target) { for(int i=source;i<target;i++){ if(str[i] ==

2013-03-29 20:29:11 667

原创 字符串全排列

#include using namespace std;void swap(char* s1,char* s2) { char temp = *s1; *s1=*s2; *s2=temp;}void perm(char* str,int index){ if(str[index]=='\0'){ cout<<str<<endl; return; } for(int

2013-03-29 20:04:33 383

原创 广度遍历二叉树

#include using namespace std;int count = 0;class BinTree{public: BinTree(int v){ value = v; left = NULL; right = NULL; } int value; BinTree* left; BinTree* right;};class Node{public:

2013-03-29 15:45:32 360

原创 链表逆置

#include using namespace std;class List {public: List(int num) { this->num = num; } int num; List* next;};//创建链表List* createList(int count) { if(count == 0 ) return

2013-03-29 14:32:15 397

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除