Skip to content

Commit

Permalink
剑指Offer--040-数组中只出现一次的数字--http://blog.csdn.net/gatieme/article/detail…
Browse files Browse the repository at this point in the history
  • Loading branch information
gatieme committed Aug 1, 2016
1 parent 6b3020a commit 5823f96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions 041-和为S的两个数字/find.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <iostream>
#include <vector>


using namespace std;


// 调试开关
#define __tmain main

Expand All @@ -19,7 +21,9 @@ using namespace std;

class Solution
{
public:

public :

vector<int> FindNumbersWithSum(vector<int> array,int sum)
{
vector<int> res;
Expand All @@ -40,7 +44,7 @@ class Solution
{
/// 左右夹逼
/// 同时能保证乘积最小的
/// 和为sum的最大的两个数最接近sqrt(sum)
/// 和为sum的最大的两个数最接近sqrt(sum)
res.push_back(array[start]);
res.push_back(array[end]);

Expand Down
3 changes: 3 additions & 0 deletions 041-和为S的连续正数序列/find.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <iostream>
#include <vector>


using namespace std;


#define __tmain main

#ifdef __tmain
Expand Down Expand Up @@ -31,6 +33,7 @@ class Solution

int begin = 1, end = 2, mid = (sum + 1) / 2;
int currSum = begin + end;

while(begin < mid && end < sum)
{
/// 和正好是sum的话, 就存储下来
Expand Down

0 comments on commit 5823f96

Please sign in to comment.