自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 百度三面:找出数组中所有这样的数,大于等于左边的所有数,小于等于右边的所有的数

#include using namespace std;void func(int *a, int len, int &b1, int &b2){ int a1, a2; b1 = a1 = 0; b2 = a2 = len-1; int l_min, r_max; l_min = a[a1]; r_max = a[a2]; while(a1<a2) { if(a[

2013-10-16 20:43:51 666

原创 n后问题

关键问题:不在同行,同列,斜线上。即对任意两行,!(x[r1]==x[r] || abs(r1-r)==abs(x[r1]-x[r]))。用回溯法,通过此条件进行减枝。#include using namespace std;void print(int *x, int n){ int i, j; for(i=0; i<n; i++) { for(j=0; j<n; j

2013-10-06 12:57:06 646

原创 输出递增数组中和为sum的两个数

算法本身不复杂,但是提供了一个跟有序数组相关的一个思路:记录首尾指针,由两边向中间缩进。#include using namespace std;bool findPairWithSum(int* a, int len, int sum, int& n1, int& n2){ if(a==NULL || lena[len-1]+a[len-2]) return false;

2013-10-05 23:18:08 1110 1

原创 数组中的逆序对

比归并排序只多了一句输出。#include using namespace std;void getInversePair(int* a, int* b, int low, int mid, int high){ int l=low, m=mid+1, k=low, j; while(l<=mid && m<=high) { if(a[l]>a[m]) { f

2013-10-05 14:18:53 570

原创 第一个只出现一次的字符

#include using namespace std;#define min(x, y) (x)<(y)?(x):(y) char getFirstSingleChar(char* s){ if(s==NULL || *s==0) return 0; int len = strlen(s); unsigned int h_table[256] = {0}; int i

2013-10-05 13:46:56 559

原创 丑数,只包含因子2、3、5的数

#include using namespace std;#define min(x, y) (x)<(y)?(x):(y) int getUglyNumber(int index){ if(index<0) return 1; int* nums = new int[index]; nums[0] = 1; int next_id = 1; int* ugly2

2013-10-05 13:30:26 791

原创 给定一系列字符串集合,合并有交集的集合,合并完后集合之间无交集

#pragma warning(disable:4786)#include #include #include #include using namespace std; int main(){ //初始化数据 vector > v; vector v1; v1.push_back("aaa"); v1.push_back("bbb"); v1.push_b

2013-10-04 23:00:00 970

转载 memcached

基本问题1、memcached的基本设置1)启动Memcache的服务器端# /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached.pid-d选项是启动一个守护进程,-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,

2013-10-04 13:55:23 560

原创 用map求交集

#include #include using namespace std;int main(){ int a[] = {1,2,3,4,5,6,7,8,9}; int b[] = {2,4,6,8,10}; int c[10]; map m; int len_a = sizeof(a)/sizeof(a[0]); int len_b = sizeof(b)/sizeof(

2013-10-04 00:04:13 2542

原创 剑指offer-33:把数组排成最小的数

#include using namespace std;const int N = 20;char s[N][N];char com1[2*N+1];char com2[2*N+1];int comp(const void *v1, const void *v2){ strcpy(com1, (char*)v1); strcat(com1, (char*)v2); str

2013-10-03 15:37:04 567

原创 最长回文:动态规划

#include using namespace std;void huiwen(char* a){ if(a==NULL) return ; int len = strlen(a); bool table[100][100] = {false}; int max, max_id; int i,j; for(i=0; i<len; i++) table[i][i] =

2013-09-28 23:37:26 544

原创 百度笔试:最长回文(中心扩展法)

#include using namespace std;void huiwen(char* a, int& max, int& max_id){ if(a==NULL || *a=='\0') { max = 0; max_id = 0; return ; } int len = strlen(a); int i, k1, k2; max = 1; max_id

2013-09-28 23:23:40 735

原创 百度笔试:求大于n的最小的不重复数,不重复数是指相邻两个数不相同

#include using namespace std;int next_norepeat(unsigned int n){ int pow, i, j; i=++n; pow=0; while(i) { pow++; i/=10; } int *a = new int[pow+1]; a[0] = 0; for(i=pow, j=n; i>0; i--, j

2013-09-28 22:27:29 1121 2

原创 组合

#include #include using namespace std; //函数功能 : 从一个字符串中选m个元素//函数参数 : pStr为字符串, m为选的元素个数, result为选中的//返回值 : 无void Combination_m(char *pStr, int m, vector &result){ if(pStr == NULL ||

2013-09-27 20:21:42 545

原创 将二叉搜索树转换成双向链表

#include #include using namespace std; struct node{ int data; node* lchild; node* rchild;}; node* buildBTree(int* a, int &i){ if(a==NULL || a[i]==-1)

2013-09-27 18:56:57 573

原创 二叉树中和为某一值的路径

#include #include using namespace std; struct node{ int data; node* lchild; node* rchild;};void find_path(node* r, int exceptedSum, vector &path, int& curSu

2013-09-27 13:33:31 485

原创 打印1到最大的n位数

剑指offer用的是字符串,还要苦逼的字符串比较,看是否进位。直接用整型数组来保存。#include #include using namespace std; //一个int保存几位数const int int_num = 2;//每位数最大值,超过这个要进位(不包括最高位)const int int_max = 99; void func(){

2013-09-26 17:00:31 426

原创 链表翻转,每k个进行翻转

链表翻转。给出一个链表和一个数k,比如链表1→2→3→4→5→6,k=2,则翻转后2→1→4→3→6→5,若k=3,翻转后3→2→1→6→5→4,若k=4,翻转后4→3→2→1→5→6#include using namespace std;struct node{ int data; node* next;};node* init(int n){ n

2013-09-19 22:49:28 638

原创 利用二级指针删除节点

#include using namespace std;struct node{ int data; node* next;};void remove(node** head, int value){ if(head == NULL) return ; node** n = head; node* cur; while

2013-09-18 17:29:39 484

原创 已知先序,中序,求后序

#include using namespace std;void func(int* pre, int* mid, int pre_left, int pre_right, int mid_left, int mid_right){ if(pre_left == pre_right) { cout<<pre[pre_left

2013-09-18 16:18:10 626

原创 判断平衡二叉树,创建二叉树,先序遍历二叉树

#include using namespace std;struct node{ int data; node* lchild; node* rchild;};bool is_banance_tree(node* r, int& height){ if(r == NULL) { height = 0; retu

2013-09-17 23:58:14 503

原创 拷贝构造函数,赋值运算符重载,友元输出重载

#include using namespace std;class T{public: T():buf(NULL){} T(char *s) { buf = new char[strlen(s) + 1]; strcpy(buf, s); } T(const T& t) { char* t_

2013-09-16 14:01:01 632

原创 KMP

#include using namespace std;void set_next(int* next, char *s){ int k, j; int len = strlen(s); next[0] = -1; for(k=1; k<len; k++) { j = k-1; while(1) {

2013-09-16 11:27:23 529

原创 句子反转,单词不反转

#include using namespace std;void reverse(char* s,int left, int right){ while(left<right) { swap(s[left], s[right]); left++; right--; }}void reverse_sentence

2013-09-15 20:10:35 760

原创 链表 快排

注意指向指针的指针的应用。#include #include using namespace std;struct node{ int data; node* next;};node* partion(node** head, node* end){ // coutdata<<" "; // if(end==NULL) //

2013-09-14 01:41:41 671

原创 1~n,1出现的次数

主要思想,分别考虑每位(个位,十位,不是二进制的位)为1的情况,特别考虑最高位是1和不是1的情况。使用递归,如 f(253)=f(200)+f(50)+f(3)#include #include using namespace std;int f1(int n){ int i, j, k; int num_1=0; for(i=0; i<=n; i++)

2013-09-11 13:00:54 598

原创 链表反转,递归,迭代

#include using namespace std;struct node{ int data; node* next;};node* reverse_link(node* head){ if(head==NULL || head->next==NULL) return head; node* pre; node

2013-09-11 01:39:53 670

原创 最大子数组和

#include using namespace std;void f(){ int a[] = {-6,-8, -5, -9}; int len = sizeof(a)/sizeof(a[0]); int sum = a[0] ; int d = a[0]; int i; for(i=1; i<len; i++) {

2013-09-10 21:35:12 558

原创 最长递增子序列

#include using namespace std;#define N 1000int max_len = 0;int max_right_id = 0;char s[N];int c[N];int pre[N];void print(int id){ if(pre[id] == -1) { cout<<max_len<<": "<<

2013-09-10 21:14:08 537

原创 最长重复子串——后缀数组

#include #include using namespace std;#define N 100char s[N];char suf[N][N];int max_same = 0;int comp(const void *s1, const void* s2){ return strcmp((char*)s1, (char*)s2);}int ge

2013-09-10 20:29:42 516

原创 C++ 继承,虚表内容

#include using namespace std; class D{ public: virtual void d(){cout<<"D::d"<<endl;} // int dd; };class ClassA : public virtual D{public:virtual ~ ClassA(){};virtual void FunctionA(){cout

2013-09-10 13:08:23 552

原创 找出只出现一次的数,其他数都出现了k次

#include using namespace std;int k=3;int find_single(int* a, int n){ int i, j; int single = 0; int temp[32]; for(i=0; i<32; i++) temp[i] = 0; for(i=0; i<n; i

2013-09-08 12:15:15 661

原创 最短路径 Dijkstra

#include #include using namespace std;const int N = 20;const int MAX_DIS = 10000;int dis[N]; //v0到i的最短路径长度int pre[N]; //节点i的前驱int dd[N][N]; //节点之间距离int sort_id[N]; //记录dis[n]排序后的下标,关键int n

2013-09-07 22:23:49 502

原创 字符串排序

后缀数组中,需要排序字符串:#include #include using namespace std;int comp(const void* p1, const void* p2){ return strcmp((char*)p1, (char*)p2);}int main(){ char s[5][6] = {"abc", "abcd", "bcde",

2013-09-07 13:05:38 538

原创 字符串循环移位

#include using namespace std;void reverse_str(char* s, int l, int h){ while(l<h) { swap(s[l++], s[h--]); }}void left_rotate_reverse(char* s, int k, int n){ reverse_str(

2013-09-05 14:47:44 377

原创 编辑距离

距离:插入:1删除:1替换:2,(1也行,改下代码变2为1)#include using namespace std;const int N = 100;int d[N][N];char s1[N], s2[N];inline int three_min(int x, int y, int z){ int a = x<y?x:y; return a<

2013-09-05 13:31:38 441

原创 去重全排列

#include using namespace std;bool is_swap(char* a, int i, int j){ while(i<j) { if(a[i] == a[j]) return false; i++; } return true;}void print_a(char*

2013-09-03 13:30:28 485

原创 1~3000所有包含5,6的数(如56,526,1635)的和

#includeusing namespace std;const int contain_num[] = {5,6};const int num_len = sizeof(contain_num)/sizeof(contain_num[0]);const int MAX = 3000;bool b_has[10] = {false};bool if_contain(int n);

2013-09-02 21:38:02 567

原创 质因数分解

#includeusing namespace std;void func(int n){ int i; for(i=2; i<n; ) { if(n%i == 0) { cout<<i<<"*"; n /= i; } else i

2013-09-02 21:35:00 461

原创 约瑟夫环

72个人,从第9个人开始报数,报到11的人退出,下一位继续从1开始报数,问最后一个人编号。#includeusing namespace std;const int NUM = 72;struct node{ int value; node* next;};void func(){ int i; node* head = new node;

2013-09-02 21:33:55 461

高质量C++&C 编程指南

高质量C++&C 编程指南 高质量C++&C 编程指南 高质量C++&C 编程指南

2011-06-02

usb_20 usb_20 usb_20 usb_20

CHAPTER 1 INTRODUCTION 1.1 Motivation .............................................................................................................................................. 1 1.2 Objective of the Specification ............................................................................................................... 1 1.3 Scope of the Document .......................................................................................................................... 2 1.4 USB Product Compliance ..................................................................................................................... 2 1.5 Document Organization........................................................................................................................ 2 CHAPTER 2 TERMS AND ABBREVIATIONS CHAPTER 3 BACKGROUND 3.1 Goals for the Universal Serial Bus ..................................................................................................... 11 3.2 Taxonomy of Application Space......................................................................................................... 12 3.3 Feature List .......................................................................................................................................... 13 CHAPTER 4 ARCHITECTURAL OVERVIEW 4.1 USB System Description ....................................................

2011-06-02

含有zip.lzw.gzip等多种压缩算法的程序

含有zip.lzw.gzip等多种压缩算法的程序 含有zip.lzw.gzip等多种压缩算法的程序 含有zip.lzw.gzip等多种压缩算法的程序

2010-10-28

人机对战五子棋 c++源码

人机对战五子棋 c++源码 人机对战五子棋 c++源码 人机对战五子棋 c++源码

2010-10-28

八皇后问题 八皇后问题 八皇后问题

八皇后问题 ,程序代码 八皇后问题 ,程序代码 八皇后问题 ,程序代码

2010-10-28

图书管理系统VC6.0+sql2005

图书管理系统,基于VC6.0+sql2005,附带课程设计,数据等

2010-10-28

poi.rar poi excel reader

用于提取excel内容到文本文件。 poi读取excel文件的cell类型,主要有CELL_TYPE_STRING和CELL_TYPE_NUMERIC

2010-05-08

播放器程序,由C#实现,可以播放多种形式的电影

播放器程序,由C#实现,可以播放多种形式的电影,能够调整播放进度、声音、屏幕大小,全屏显示,并能记住上次打开电影的文件路径和声音大小。

2009-12-09

自动售饮料机(包括顾客购买饮料、添加饮料、收银员提取现金)

本程序可以实现顾客购买饮料、添加饮料、收银员提取现金等操作。饮料的存储量、名称种类、单价等相关信息已保存,可供下次程序运行是使用。

2009-07-05

学生成绩管理系统(可以按照多种方式对学生成绩进行查询)

本程序将输入的学生的信息存储到stuscore.dat文件中,在每次程序运行开始时都会将信息读入到str[]数组中,然后在开始对学生成绩等信息的相关操作,操作完毕,将stuscore.dat文件更新,结束程序。程序中对学生的成绩进行了排名,可以按照多种方式对学生成绩进行查询。

2009-07-05

Linux系统分析与高级编程技术

本书介绍Linux环境下的编程方法,内容包括Linux系统命令、 Shell脚本、编程语言(gawk、Perl)、系统内核、安全体系、X Window等,内容丰富、论述全面,涵盖了Linux系统的方方面面。

2009-06-12

约瑟夫环(没有用到栈,依然很简单)

编号为1,2,•••,n的n个人围坐在一圆桌旁,从第s个人开始报数,报到第m的人退席,下一个人又重新从1开始报数,依此重复,直至所有的人都退席。 例如,设s=1,m=4,n=8,则退席的人的编号依次为4,8,5,2,1,3,7,6。

2009-04-26

多项式加法与乘法(包括计算后的多项式以及结果)

实现多项式的加法与乘法,并且按照x幂的降序输出计算后的多项式以及结果。

2009-04-26

空空如也

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

TA关注的人

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