update linkedHashmap

This commit is contained in:
ranwenjie
2021-09-01 10:08:04 +08:00
parent 573f5b3811
commit 92d58f76b1
2 changed files with 39 additions and 18 deletions
+21 -2
View File
@@ -10,10 +10,24 @@
要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
思路:这是等差数列求和公式, 1+2+3.......+N =(n+1)n/2
分析:
1. 不能使用循环,那就用递归
2. 递归需要终止递归的条件判断语句,这里也不能用if,想其他办法,可以使用 &&逻辑与 运算符(在n>0条件满足是,才会指向后面的递归语句
```
int (n){
int sum=0;
(n>0) && sum=n+factorial(n-1)
return sum;
}
```
## 大数阶乘(factorial)
```
int factorial(n){
int sum=0;
@@ -23,6 +37,8 @@ int factorial(n){
```
## 整数的二进制表示中1的个数
题目:输入一个整数,求该整数的二进制表达中有多少个1。例如输入10,由于其二进制表示为1010,有两个1,因此输出2。
@@ -79,13 +95,16 @@ tmp[i] = tmp[i]>=0 ? tmp[i] : tmp[i]+16;
## ipv4 转 int
比如: 10.67.81.35 , 转为int 为
比如: 127.0.0.1 , 转为int 为 (01111111 00000000 00000000 00000001)
思路:
```
代码
int toInt(){
}
```
那么,int 转 ipv4 如何解呢?