02 2016 档案
摘要:一天,他提着酒壶,从家里出来,酒壶中有酒2斗。他边走边唱: 无事街上走,提壶去打酒。 逢店加一倍,遇花喝一斗。 这一路上,他一共遇到店5次,遇到花10次,已知最后一次遇到的是花,他正好把酒喝光了。求可能的方案总数。我的方法: size_t num_solutions = 0; void keepWa
阅读全文
摘要:bool checkSame(std::string a, std::string b) { constexpr int size = 145; std::vector<int> count(145); std::for_each(a.cbegin (), a.cend (), [&](char c
阅读全文
摘要:class ThreadRAII { public: // whether join or detach should be called, // when a this object is destroyed. enum class DtorAction { join, detach }; Thr
阅读全文
摘要:class Node; using NodePtr = std::unique_ptr<Node>; class Node { public: int value; NodePtr next = nullptr; explicit Node(int value_ = 0): value(value_
阅读全文
摘要:int convert(char buf[], int value) { constexpr char digits[] = {'9', '8', '7', '6', '5', '4', '3', '2', '1', '0', '1', '2', '3', '4', '5', '6', '7', '
阅读全文
摘要:struct Node { int value = 0; Node* next = nullptr; Node(int value_) : value(value_) {} }; Node* createLinkList(const std::vector<int>& data) { if (dat
阅读全文
摘要:最基本的快排: int partition(int arr[], int l, int r) { int k = l; int pivot = arr[r]; for (int i = l; i != r; ++i){ if (arr[i] < pivot){ std::swap(arr[i], a
阅读全文