SelectionSort,选择排序,C++实现
摘要:1 // g++ selection_sort.cc -Wall -O3 -std=c++11 && ./a.exe 2 3 4 #include <iostream> 5 #include <vector> 6 7 8 static void swap(int &a, int &b) { 9 in
阅读全文
posted @
2020-09-14 17:51
_bob
阅读(164)
推荐(0) 编辑
BubbleSort,冒泡排序,C++非递归和递归实现
摘要:1 // g++ bubble_sort.cc -Wall -O3 && ./a.exe 2 3 4 #include <iostream> 5 #include <vector> 6 7 8 static void swap(int &a, int &b) { 9 b = a + b; 10 a
阅读全文
posted @
2020-09-14 16:39
_bob
阅读(199)
推荐(0) 编辑
匿名Lambda函数,C++
摘要:1 // To Compile and Run: g++ -std=c++11 lambda.cc -Wall -O3 && ./a.out 2 3 4 #include <iostream> 5 6 7 int main() { 8 int c = 12; 9 10 std::cout 11 <<
阅读全文
posted @
2020-09-13 23:53
_bob
阅读(129)
推荐(0) 编辑
链表反转,C++实现
摘要:1 // To Compile and Run: g++ invert_list.cc -std=c++11 -Wall -O3 && ./a.out 2 3 4 #include <iostream> 5 #include <vector> 6 7 8 class ListNode { 9 pub
阅读全文
posted @
2020-09-13 22:48
_bob
阅读(317)
推荐(0) 编辑
BinarySearch,逆序排列的数组的二分查找(折半查找),C++非递归+递归实现
摘要:1 // To Compile and Run: g++ binary_search.cc -std=c++11 -Wall -O3 && ./a.out 8 2 3 4 #include <stdlib.h> 5 #include <assert.h> 6 7 #include <iostream
阅读全文
posted @
2020-09-13 00:35
_bob
阅读(246)
推荐(0) 编辑
Two Sum:给出一个整数数组,返回两个数的下标值,令其和等于一个指定的目标值 #Leetcode
摘要:// Given nums = [2, 7, 11, 15], target = 9, // Because nums[0] + nums[1] = 2 + 7 = 9, // return [0, 1]. #include <iostream> #include <vector> int GetI
阅读全文
posted @
2020-09-06 22:10
_bob
阅读(225)
推荐(0) 编辑