Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
imgss committed Jul 23, 2018
1 parent b86c01b commit c2e60e9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Algorithm/algorithm-ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

**面试题**:两个数不使用四则运算得出和

这道题中可以按位异或,因为按位异或就是不进位加法,`8 ^ 8 = 0` 如果进位了,就是 16 了,所以我们只需要将两个数进行异或操作,然后进位。那么也就是说两个二进制都是 1 的位置,左边应该有一个进位 1,所以可以得出以下公式 `a + b = a ^ b + (a & b) << 1` ,然后通过迭代的方式模拟加法
这道题中可以按位异或,因为按位异或就是不进位加法,`8 ^ 8 = 0` 如果进位了,就是 16 了,所以我们只需要将两个数进行异或操作,然后进位。那么也就是说两个二进制都是 1 的位置,左边应该有一个进位 1,所以可以得出以下公式 `a + b = (a ^ b) + ((a & b) << 1)` ,然后通过迭代的方式模拟加法

```js
function sum(a, b) {
Expand Down
4 changes: 1 addition & 3 deletions JS/JS-ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,6 @@ for ( var i=1; i<=5; i++) {
}
```

因为对于 `let` 来说

第三种就是使用 `let` 定义 `i`

```js
Expand Down Expand Up @@ -1450,7 +1448,7 @@ parseFloat((0.1 + 0.2).toFixed(10))
| 元字符 | 作用 |
| :----: | :----------------------------------------------------------: |
| . | 匹配任意字符除了换行符 |
| . | 匹配任意字符除了换行符和回车符 |
| [] | 匹配方括号内的任意字符。比如 [0-9] 就可以用来匹配任意数字 |
| ^ | ^9,这样使用代表匹配以 9 开头。[`^`9],这样使用代表不匹配方括号内除了 9 的字符 |
| {1, 2} | 匹配 1 到 2 位字符 |
Expand Down
2 changes: 1 addition & 1 deletion JS/JS-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ parseFloat((0.1 + 0.2).toFixed(10))
| Metacharacter | Effect |
| :-----------: | :----------------------------------------------------------: |
| . | matches any character except the new line character |
| . | matches any character except line terminators: \n, \r, \u2028 or \u2029. |
| [] | matches anything within the brackets. For example, [0-9] can match any number |
| ^ | ^9 means matching anything that starts with '9'; [`^`9] means not matching characters except '9' in between brackets |
| {1, 2} | matches 1 or 2 digit characters |
Expand Down

0 comments on commit c2e60e9

Please sign in to comment.