
剑指offer
文章平均质量分 72
wyj7260
这个作者很懒,什么都没留下…
展开
-
05_从尾到头打印链表
#include #include using namespace std;typedef struct ListNode { int data; struct ListNode * next; ListNode(int d) : data(d), next(NULL){}};ListNode *initList() { ListNode * head = NULL;原创 2014-09-06 13:22:02 · 1170 阅读 · 0 评论 -
剑指offer_02_二维数组中的查找
#include using namespace std;bool ifHasNum(int *data,int row, int col, int num){ if(data == NULL || row <= 0 || col <= 0){ return false; } int i = 0; int j = col - 1; while(i = 0){ if(nu原创 2014-09-06 10:34:20 · 800 阅读 · 0 评论 -
11_数值的整数次方
#includeusing namespace std;bool isValid = true;bool isPositive = true;bool doubleEqual(double number1, double number2) { if(number1 - number2 -0.0000001) { return true; } else { return原创 2014-09-06 15:59:54 · 601 阅读 · 0 评论 -
09_斐波那契数列
#include#include#include using namespace std;long long fibRecursion(unsigned n) { if(n <= 0) { return 0LL; } if(n == 1) { return 1LL; } if(n >= 2) { return fibRecursion(n - 1) +原创 2014-09-06 14:22:38 · 904 阅读 · 0 评论 -
10_二进制中1的个数
#includeusing namespace std;int main() { unsigned int number = 9; cout<<"number:"<<number<<endl; int count_one = 0; while(number) { count_one++; number = number & (number - 1); }原创 2014-09-06 14:50:44 · 540 阅读 · 0 评论 -
017_合并两个排序的链表
#include #include using namespace std;typedef struct ListNode { int data; struct ListNode * next; ListNode(int d) : data(d), next(NULL){}};ListNode *initList(int *array, unsigned int lengt原创 2014-09-06 22:05:29 · 798 阅读 · 0 评论 -
031_连续子数组的最大和
#include #include using namespace std;bool isValid = true;int FindGreatestSumOfSubArray(int *data, int length) { isValid = true; if (data == NULL || length == 0) { isValid = false; return原创 2014-09-07 16:54:38 · 730 阅读 · 0 评论 -
057_删除聊表中的重复的节点
#include #include using namespace std;typedef struct ListNode { int data; struct ListNode * next; ListNode(int d) : data(d), next(NULL){}};ListNode *initList(int *array, unsigned int lengt原创 2014-09-13 22:32:28 · 848 阅读 · 0 评论 -
042_翻转单词顺序
/**Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without u原创 2014-10-04 15:41:38 · 997 阅读 · 0 评论