switch 语句用于基于不同条件执行不同动作。 JavaScript Switch 语句 请使用 switch 语句来选择多个需被执行的代码块之一。 语法 switch(表达式) { case n: 代码块 break; case n: 代码块 break; default: 默认代码块 } 代码 ...
分类:
编程语言 时间:
2020-07-05 15:40:33
阅读次数:
207
循环可多次执行代码块。 JavaScript 循环 假如您需要运行代码多次,且每次使用不同的值,那么循环(loop)相当方便使用。 通常我们会遇到使用数组的例子: 不需要这样写: text += cars[0] + "<br>"; text += cars[1] + "<br>"; text += ...
分类:
编程语言 时间:
2020-07-05 15:21:46
阅读次数:
124
JavaScript Math 对象允许您对数字执行数学任务。 实例 Math.PI; // 返回 3.141592653589793 亲自试一试 Math.round() Math.round(x) 的返回值是 x 四舍五入为最接近的整数: 实例 Math.round(6.8); // 返回 7 ...
分类:
编程语言 时间:
2020-07-05 15:09:40
阅读次数:
99
package dao;import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.text.NumberFormat;import java.util.ArrayLis ...
分类:
其他好文 时间:
2020-07-05 10:51:05
阅读次数:
49
这道题的题意是,给出一个一维数组,数组中的元素只可能是0,1,2,分别表示红色、白色和蓝色。 我们需要做一个排序,使得0全部在数组前面,1在中间,2在后面。 (不过不能用sort函数) 方法一(常数空间,非一趟扫描) 可以用三个变量分别记录红色、白色和蓝色的出现次数,然后根据出现的次数,修改数组即可 ...
分类:
其他好文 时间:
2020-07-05 01:00:37
阅读次数:
80
public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> result = new ArrayList<>(); if(nums.length < 3)return result; Arrays.sort(nums); ...
分类:
其他好文 时间:
2020-07-04 22:39:06
阅读次数:
63
Description 思路 cf题解中合法的x的处于一段连续区间不太明白。在知道这个前提下,将E1的代码改成二分即可。 有空再补回来。 #include <iostream> #include <cstdio> #include <queue> #include <algorithm> #incl ...
分类:
其他好文 时间:
2020-07-04 19:00:50
阅读次数:
82
列表 list在循环的时候不能删,因为会改变索引 ls = ['aaa', 'bbb', 'ccc', 'ddd'] for el in ls: print(el) ls.remove(el) print(ls) 结果: aaa ccc ['bbb', 'ddd'] names = ["aa", ' ...
分类:
编程语言 时间:
2020-07-04 18:51:57
阅读次数:
54
React路由传参的三种方式 方式 一: 通过params 1.路由表中 <Route path=' /sort/:id ' component={Sort}></Route> 2.Link处 HTML方式 <Link to={ ' /sort/ ' + ' 2 ' } activeClassNam ...
分类:
其他好文 时间:
2020-07-04 18:42:03
阅读次数:
57
找bug 看例子: test_scores = [100, 97, 76, 84, 93, 98, 86, 92, 76, 88, 95, 90, 95, 93] new_scores = test_scores.sort() new_scores = new_scores.reverse() pr ...
分类:
其他好文 时间:
2020-07-04 13:11:41
阅读次数:
80