自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 收藏
  • 关注

原创 c语言中的字符串问题

#includeint main(){ int n; char y[10]="abcde"; char* x=y; n=strlen(x); //printf("%d\n",n); *x=x[n]; x++; printf("%s\n",x); printf("%s\n",y); return 0;}输出结果为: bcde结果分析:char*

2013-10-01 17:09:49 476

原创 l两个字符串相关问题

将一个字符串str1中被字符串str2包含的字符去掉,去掉一个字符串中重复的字符。判断两个字符串的字母以及出现次数是否相同。用额外的空间去存储一个字符串中的信息,提升速度。#include#includeusing namespace std;//delete the char in str that occured in chstring FirstNotRepeat(string st

2013-09-10 00:23:27 428

原创 数组模拟bit存储

使用数组来模拟位运算,对于取值只为0,1两种的判断,一个bool类型要占用一个byte,而位运算只占用一个bit,是bool的1/8。以下是判断一个string中的字符是否完全不同,算法1是普通解法,算法2为使用数组模拟位存储的解法。红色部分为关键代码#include#includeusing namespace std;bool isUnique1(string st

2013-09-04 23:56:52 471

原创 约瑟夫环

#include#includeusing namespace std;/* 圆圈中最后剩下的数字使用了stl::list*/int lastNum(int n,int m){if(nexit;list num;for(int i=0;inum.push_back(i);list::iterator cur=num.begin()

2013-08-28 01:03:58 426

原创 连续子数组的最大和

#includeusing namespace std;/* 求连续子数组的最大和* 利用动态规划的思想*f[n]=a[n] ;n=0 | f[n-1]*f[n]=f[n-1]+a[n]   ;f[n-1]>=0*max(f[n]就是最大的和*/int GetGreateSum(int num[],int n){if(num==NULL||n

2013-08-28 00:21:46 333

翻译 求n的二进制表示中1的个数

#includeusing namespace std;int count(int num){int res=0;while(num){res++;num=num&(num-1);}return res;}int count1(int n){//当n为负数的时候出现死循环int res=0;while(n){if(n&1)

2013-07-22 23:52:38 491

原创 26进制

微软的一个面试题目,在excel表格中,A表示第1列,B表示第2列,……Z表示第26列,AA表示第27列,AB表示第28列,#includeusing namespace std;int getCol(char* ch){int res=0;int len=strlen(ch);for(int i=0;iint t=ch[i]-'A'+1;res=(res*

2013-07-22 23:31:02 644

原创 寻找旋转数组的最小值

#includeusing namespace std;int sortMin(int data[],int start,int end){int res;for(int i=start;iif(res>data[i]){res=data[i];}}return res;}//利用二分查找,来寻找两个旋转数组的最小值,int findMin(

2013-07-22 22:14:28 442

原创 实现的快排

#include using namespace std;int position(int data[],int begin,int end){//将data[end]作为分隔值if(data==NULL||beginreturn -1;int p=begin-1;//在begin与p之间,包含p处,这段区间的值都小于data[end],p+1为下一个存放小

2013-07-21 22:48:57 412

原创 两个队列实现一个栈的功能

#include #include #include using namespace std;template class CStack{public:CStack();~CStack();void cpush(const T& val);T cpop();//pop的时候有返回值,这个是为了测试而是用的private:queue que1;

2013-07-21 16:45:47 508

原创 利用两个栈实现一个队列

#include #include #include using namespace std;template class CQueue{public:CQueue(void);~CQueue(void);void appendTail(const T& node);T deleteHead();private:stack stack1;s

2013-07-21 16:44:12 411

原创 二叉树遍历

#include#include#includeusing namespace std;typedef struct BNode{int val;struct BNode* left;struct BNode* right;}BNode;BNode* create(int* pStart,int* pEnd,int* iStart,int

2013-07-14 22:57:13 364

原创 LinkList的create,delete,print

LinkList中指针的操作比较多,今天总算是搞明白了,先把代码记录一下。#include #includeusing namespace std;typedef struct LinkNode{int val;struct LinkNode * next;}LinkNode;LinkNode * CreateLinkNode(int

2013-07-07 23:14:58 1027

空空如也

空空如也

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

TA关注的人

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