MUSHANK

Keep Hungry Keep Foolish

iTerm2 Usage

标签 新建标签:command + t 关闭标签:command + w 切换标签:command + 数字 / command + 左右方向键 屏幕 垂直分屏:command + d 水平分屏:command + shift + d 切换屏幕:command + option + 方向键 / command + [ / command + ] 清屏:command + r...

VIM Usage

1. 模式切换 i // 按i进入Insert模式 ESC// 按ESC返回Normal模式 :help <command>// 显示相关命令的帮助(退出帮助需要:q) 2. 移动光标 hjkl // 移动光标,分别为『左』『下』『上』『右』(光标键← ↓ ↑ →也可以) 0// 移动至行首(数字零) $/...

词频统计与排序(三)

C++/STL/Map容器实现

采用STL中的Map容器实现词频统计与排序,代码如下: #include <iostream> #include <string> #include <map> using namespace std; // 引入了map int main() { // 输入 string strI...

词频统计与排序(二)

C++/STL/Set容器实现

采用STL中的Set容器实现词频统计与排序,代码如下: #include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> using nam...

词频统计与排序(一)

C++/STL/Vector容器实现

采用STL中的Vector容器实现词频统计与排序,代码如下: #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; int main() { string...

Tail-Recursion Optimization

采用Python代码进行演示,但其本身不支持尾递归优化

尾递归和普通递归的不同在于对内存的占用,普通递归创建stack累积而后计算收缩,尾递归只占用恒量的内存(类似迭代)。可以通过尾递归优化来避免普通递归可能造成的爆栈问题。 以下采用Python代码举例: 普通递归 def power(x): if x == 1: return x else: return x * p...

Maximum Subsequence Sum

C语言实现

一、问题描述 给定N个整数的序列{A1,A2······An},求f(i,j) = max(连续子序列和)。 二、代码实现 算法一: 循环遍历 这是最为常见的一种求解方式,采用循环遍历的方式求出最大连续子列和,T(n) = O(n^2) int maxSubSeqSum(int A[], int N){ int thisSum = 0; int maxSum = 0...

Prime Number List

C语言实现

一、问题描述 欲构造n以内(不含n)的素数表,分析如下: 令x为2; 将2x,3x,4x直至ix<n的数标记为非素数; 令x为下一个没有被标记为非素数的数,重复2;直到所有的数都标记完毕 伪代码描述: 开辟prime[n],初始化其所有数为1,prime[x]=1表示x为素数; 令x=2; 若x为素数,则对(i=2,ix<n,i++),令pri...