- 博客(18)
- 收藏
- 关注
原创 关于二叉树的相关操作
//关于二叉树的相关操作 #include #include #include #include typedef struct _tree { char data; struct _tree *lchild; struct _tree *rchild; int ltag;//用于二叉树的线索化; int rtag;//用于二叉树的线索化; }*ptree,tree
2012-06-16 23:48:16
764
转载 linux下VIM插件介绍及安装
//cscope http://blog.chinaunix.net/u1/46984/showart_514862.html http://www.yjpub.com/index.php/1081 http://blog.china.alibaba.com/blog/zhiqing20091027/article/b0-i8840186.html http://hi.baidu.com/
2012-05-26 07:58:41
2428
转载 TLB刷新的深入理解
为何linux内核的leave_mm中最后有一个load_cr3,这样的话岂不是又加载了cr3,这样岂不是违背了懒惰模式懒惰刷新tlb的初衷吗?这是邮件列表中很多人问的一个问题,要回答这一个问题,还要从2.6.18内核谈起。在2.6.18以及以前的内核中,leave_mm中是没有laod_cr3的,可是后来就有了,到底为什么?这一个要从cpu硬件的预取谈起。 每个cpu为了效率,几乎都会提前好几
2012-05-19 23:02:22
3616
原创 数据结构-模拟银行业务
#include #include #include #include #define WINDOWS 10 //定义窗口数 typedef struct _Event//事件结构体 { struct _Event *next; int OccurTime;//事件发生时刻 int NType;//事件类型(0表示客户到来,其他表示客户离开) }EventType,*E
2012-04-01 21:41:04
1119
原创 kmp算法实现的字符串匹配
#include #include int next[50]; void get_next(char *T,int *next)//求模式串的next数组 { int i=1,j=0; next[1]=0;//由定义知 while(i { if(j==0||T[i]==T[j]) { ++i; ++j; next[i]=j; }
2012-03-22 23:50:19
518
原创 关于循环移位
怎样降低循环移位的复杂度?我是通过交换来达到目的,有更好的方法吗 #include #include int main() { int i,count=0,k,tmp,m,n,t,flag=0;//tmp是辅助结点 printf("请输入所移位数\n"); scanf("%d",&k); i=k-1; t=i; printf("请输入你希望的数字位数\n");
2012-03-16 22:49:35
609
原创 数组指针问题(求指教)
#include using namespace std; int main() { float(**q)[5]; float a[1][5]={{1,2,3,4,5}}; q=&new float [1][5];//编译可以通过 //q=&a;//编译通不过 //q=new float*;//此处我原本想先给q分配一个内存空间,用于存取二维数组a的地址 //却找不到
2011-11-28 23:44:45
1066
1
原创 华北计算所其中一道机试题,逆转字符串,但是单词顺序不变,字符串中只含有字母和空格
#include using namespace std; int main() { char *a="this is a book"; char *p=a,*q=a; int i=strlen(a); while(i) { if(p[i-1]==
2011-09-18 21:59:32
1153
原创 方正面试的题-找出字符串最多的分解方法
有长度m(>3)的字符串M,另有n个3个字符长度的子字符串,可以是重叠的,(如123,231,), 分解字符串M,搜索与子字符串一样的字符串个数,并找出最多的分解方法。 #include using namespace std; char m[100][4]; char b[1000]; int c[997]; int strcpy1(char *s1,char *s) {
2011-09-18 21:55:51
546
原创 骑士聚会问题
在8×8的棋盘上分布着n个骑士,他们想约在某一格的中聚会,骑士每天可以像国际象棋中的马那样移动一次,如下图所示,可以从中间向8个方向移动,请你计算n个骑士的最早聚会地点和要走多少天。要求尽早聚会,且n个人走的总步数最少,先到聚会地点的骑士可以不再移动等候其他骑士。 从键
2011-09-18 00:31:20
1229
原创 高精度减法
#include #include #include using namespace std; void subtract(char *a,char *b) { int i,j,top=-1,k; if(strlen(a)>=strlen(b)) {
2011-09-12 20:32:53
418
原创 高精度加法
#include using namespace std; void add(char *a,char *b) { int i,j,k=0,carry; string s; char *c=(char *)malloc(sizeof(char)*(strlen(
2011-09-12 20:31:05
511
原创 高精度乘法
#include using namespace std; #define MAX 10000 char m[MAX]; char tmp[MAX]; void multip(char *a,char *b) { int j,k,i,d,h=0,e; for(
2011-09-12 20:06:00
552
原创 poj1753 flip game题解
#include using namespace std; #include #define MAX 65536 const int a[16]={ 0xc800,0xe400,0x7200,0x3100,
2011-09-06 11:45:58
641
原创 给出一个实数集合和一个实数,怎样判断集合中是否存在两个和等于该实数的元素
#include #define N 8 using namespace std; int main() { float a[N]; int i,j,mid,left,right,temp,temp1; for(i=0;i cin>>a[i]; fo
2011-08-19 23:40:29
958
原创 十字链表的创建及输出操作
#include #include using namespace std; #define M 4 //行数 #define N 4 //列数 typedef struct mtxn { int row; int col; struct mtxn
2011-08-18 19:16:37
1867
原创 int A[nSize],其中隐藏着若干0,其余非0整数,写一个函数int Func(int* A, int nSize),使A把0移至后面,非0整数移至
int A[nSize],其中隐藏着若干0,其余非0整数,写一个函数int Func(int* A, int nSize),使A把0移至后面,非0整数移至 数组前面并保持有序(按原来顺序),返回值为原数据中第一个元素为0的下标。(尽可能不使用辅助空间且考虑效率及异常问题
2011-08-17 19:58:58
5267
原创 判断字符串是否可以通过交换相邻字符得到回文字符串,如果可以输出最少交换次数
#include using namespace std; int count=1;//全局变量,计数; int count1=0;//判断奇数个字母出现的次数 int Judge(char str[]); int Circle(char str[]); int Ci
2011-08-13 11:33:48
2362
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅