Skip to content

Commit 5823f96

Browse files
committed
剑指Offer--040-数组中只出现一次的数字--http://blog.csdn.net/gatieme/article/details/51352156
1 parent 6b3020a commit 5823f96

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

041-和为S的两个数字/find.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#include <iostream>
22
#include <vector>
33

4+
45
using namespace std;
56

7+
68
// 调试开关
79
#define __tmain main
810

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

2022
class Solution
2123
{
22-
public:
24+
25+
public :
26+
2327
vector<int> FindNumbersWithSum(vector<int> array,int sum)
2428
{
2529
vector<int> res;
@@ -40,7 +44,7 @@ class Solution
4044
{
4145
/// 左右夹逼
4246
/// 同时能保证乘积最小的
43-
/// 和为sum的最大的两个数最接近sqrt(sum)
47+
/// 和为sum的最大的两个数最接近sqrt(sum)
4448
res.push_back(array[start]);
4549
res.push_back(array[end]);
4650

041-和为S的连续正数序列/find.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#include <iostream>
22
#include <vector>
33

4+
45
using namespace std;
56

7+
68
#define __tmain main
79

810
#ifdef __tmain
@@ -31,6 +33,7 @@ class Solution
3133

3234
int begin = 1, end = 2, mid = (sum + 1) / 2;
3335
int currSum = begin + end;
36+
3437
while(begin < mid && end < sum)
3538
{
3639
/// 和正好是sum的话, 就存储下来

0 commit comments

Comments
 (0)