自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

水晶莲的专栏

这个世界只有一种英雄主义,那就是认清生活的本质,仍然热爱它。

  • 博客(104)
  • 收藏
  • 关注

原创 你好世界,我来自遥远的东方,请问你是哪里的高人?

你好世界,我来自遥远的东方,请问你是哪里的高人?你好世界,我来自遥远的东方,请问你是哪里的高人?你好世界,我来自遥远的东方,请问你是哪里的高人?你好世界,我来自遥远的东方,请问你是哪里的高人?你好世界,我来自遥远的东方,请问你是哪里的高人?你好世界,我来自遥远的东方,请问你是哪里的高人?

2017-04-28 10:23:18 461

原创 不用加减乘除运算符求解两个数加减乘除

1.计算 a+b

2014-09-22 20:59:49 754

原创 C++内存对齐

请牢记以下3条原则:(在没有#pragma pack宏的情况下)1、数据成员对齐规则:结构体(struct)的数据成员,第一个数据成员放在offset为0的地方,之后的每个数据成员存储的起始位置要从该成员大小的整数倍开始(比如int在32位机子上为4字节,所以要从4的整数倍地址开始存储)。2、结构体作为成员:如果一个结构体里同时包含结构体成员,则结构体成员要从其内部最大元素大小的整

2014-09-13 20:51:39 485

转载 寻找二叉树两个结点的最低共同父节点

寻找二叉树两个结点的最低共同父节点题目:二叉树的结点的定义如下:struct TreeNode { int m_nValue; TreeNode *m_pLeft; TreeNode *m_pRight;};输入二叉树中的两个结点,输出这两个结点在数中最低的共同父结点。

2014-09-12 10:35:33 795

转载 n对括号匹配的种类

#include using namespace std;//匹配数int num=0;//判断当前n对括号是否匹配bool isMatch(int n,char* bracket){ int left_num=0,right_num=0; for(int i=0;i<2*n;++i) { if(bracket[i]=='l') left_num++; else

2014-09-11 22:20:46 569

转载 最长递减子序列

#include using namespace std; // 遍历最长递减子序列,递归法 // A - 源序列数组 // B - 通过DP求出的辅助数组 // k - 使得B[i]最大的i值 void max_dec_subseq_traverse(int* A, int* B, int k) { int i; for (i = k; i >= 0;

2014-09-11 13:54:47 508

转载 1的个数

LONGLONG Sum1s(ULONGLONG n){ ULONGLONG iCount =0; ULONGLONG iFactor =1; ULONGLONG iLowerNum =0; ULONGLONG iCurrNum =0; ULONGLONG iHigherNum =0; while (n/iFactor !=0) { iLowerNum =n -(n/iFac

2014-09-11 09:14:24 342

原创 栈的push、pop 序列

栈的push、pop 序列  题目:输入两个整数序列。其中一个序列表示栈的push 顺序, 判断另一个序列有没有可能是对应的pop 顺序。 为了简单起见,我们假设push 序列的任意两个整数都是不相等的。 比如输入的push 序列是1、2、3、4、5,那么4、5、3、2、1 就有可能是一个pop 系列。

2014-09-10 23:52:19 878

转载 Windows多线程 经典读者写着问题

//读者与写者问题 #include #include #include //设置控制台输出颜色 BOOL SetConsoleColor(WORD wAttributes) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); if (hConsole == INVALID_HANDLE_V

2014-09-10 22:39:35 526

转载 Windows 多线程(七) 生产者和消费者

首先来简化问题,先假设生产者和消费者都只有一个,且缓冲区也只有一个。这样情况就简便多了。    第一.从缓冲区取出产品和向缓冲区投放产品必须是互斥进行的。可以用关键段和互斥量来完成。    第二.生产者要等待缓冲区为空,这样才可以投放产品,消费者要等待缓冲区不为空,这样才可以取出产品进行消费。并且由于有二个等待过程,所以要用二个事件或信号量来控制。

2014-09-10 14:59:20 692

转载 windows 多线程 (六) 信号量Semaphore

首先也来看看如何使用信号量,信号量Semaphore常用有三个函数,使用很方便。下面是这几个函数的原型和使用说明。第一个 CreateSemaphore函数功能:创建信号量函数原型:HANDLE CreateSemaphore(  LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,  LONG lInitialC

2014-09-10 10:53:28 751

转载 windows 多线程(五) 互斥量(Mutex)

互斥量也是一个内核对象,它用来确保一个线程独占一个资源的访问。互斥量与关键段的行为非常相似,并且互斥量可以用于不同进程中的线程互斥访问资源。使用互斥量Mutex主要将用到四个函数。下面是这些函数的原型和使用说明。第一个 CreateMutex函数功能:创建互斥量(注意与事件Event的创建函数对比)函数原型:HANDLECreateMutex(  LPSEC

2014-09-10 10:27:57 809

转载 Windows多线程(四) 经典线程同步 事件Event

第一个 CreateEvent函数功能:创建事件函数原型:HANDLECreateEvent( LPSECURITY_ATTRIBUTESlpEventAttributes, BOOLbManualReset, BOOLbInitialState, LPCTSTRlpName);函数说明:第一个参数表示安全控制,一般直

2014-09-10 09:28:13 973

转载 Windows多线程(三) 关键段 CS

本博文参考:关键段CRITICAL_SECTION 四个函数

2014-09-10 08:25:35 674

原创 Windows多线程(二)经典线程问题

声明:本文参考http://blog.csdn.net/morewindows/article/details/7442333

2014-09-10 08:13:01 685

原创 Windows多线程(一) 最简单的多线程

本篇系列参考MoreWindows系列秒杀多线程:

2014-09-09 18:30:21 5695

转载 求1+2+…+n

题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。

2014-09-09 09:32:43 388

原创 Add Binary

Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".注意chu

2014-09-08 16:15:12 340

转载 Longest Consecutive Sequence

Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longe

2014-09-08 15:55:07 322

原创 unordered_map

unordered_map#include "iostream"#include"unordered_map"using namespace std;#include int main (){ std::unordered_map mymap; std::pair myshopping ("dad",0.3); std::pair myshopping1 ("mom

2014-09-08 15:36:08 377

转载 Linked List Cycle II

Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?思路很好:

2014-09-07 10:14:17 309

转载 Validate Binary Search Tree

Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with

2014-09-07 09:50:30 340

原创 Reverse Linked List II

Reverse Linked List II

2014-09-05 16:20:28 302

转载 Candy

CandyThere are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child

2014-09-04 15:39:50 289

原创 Binary Tree Zigzag Level Order Traversal

Binary Tree Zigzag Level Order TraversalGiven a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next leve

2014-09-03 14:19:15 278

原创 Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.

2014-09-03 13:54:43 284

原创 Rotate List

Rotate ListGiven a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.

2014-09-01 16:06:35 353

原创 Search for a Range

Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log 

2014-09-01 14:48:24 318

原创 Remove Nth Node From End of List

Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2.

2014-09-01 10:26:02 295

转载 Plus One

Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.ve

2014-09-01 10:09:40 314

原创 基本排序之冒泡排序

#include"iostream"using namespace std;void Swap(int& a1,int& a2){ int t; t =a1; a1 =a2; a2 =t;}void bubblesort(int A[],int n){ for(int i=0;i<n;i++) for(int j=0;j<n-i;j++) { if(A[j]

2014-09-01 09:06:05 295

原创 Count and Say

Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.

2014-08-31 09:13:36 342

原创 Interleaving String

Interleaving StringGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.

2014-08-30 15:00:37 283

转载 Insert Interval

Insert IntervalGiven a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted accor

2014-08-30 11:20:14 306

原创 Minimum Path Sum

Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right whichminimizes the sum of all numbers along its path.Note: You can on

2014-08-29 11:01:27 280

转载 Partition List

Partition ListGiven a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative ord

2014-08-27 15:52:58 290

转载 LRU Cache

LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be

2014-08-27 15:03:03 296

转载 Linked List Cycle

Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?

2014-08-25 10:45:39 274

原创 Insertion Sort List

Insertion Sort List Sort a linked list using insertion sort.

2014-08-25 10:35:18 454

转载 Convert Sorted List to Binary Search Tree

Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.

2014-08-24 11:05:52 383

空空如也

空空如也

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

TA关注的人

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