![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
爱笑的冷眸
兴趣是最好的老师
展开
-
交换两个数的三种写法(不使用临时变量)
1、我们使用最多的当然是定义一个临时变量,然后将两个数进行交换。这个比较好理解, public static void test1(int a,int b){ System.out.println("a修改前的值"+a); System.out.println("b修改前的值"+b); int temp = a; a = b; b = a; System.out.println("a修改后的值"+a);原创 2020-10-18 16:58:10 · 1062 阅读 · 1 评论 -
找出数组中和为target的两个数的索引
public int[] twoNum(int[] nums,int target) { for (int i = 0; i < nums.length-1; i++) { for (int j = 1; j < nums.length; j++) { if(i==j) {//不能重复使用一个数 continue; } if(nums[i]+...原创 2019-11-06 11:15:17 · 369 阅读 · 0 评论 -
indexof
public static void main(String[] args) { TestIndexof test = new TestIndexof(); System.out.println(test.indexof("woaini", "i")); } public int indexof(String parent,String child) { if(parent==...原创 2019-11-06 10:17:23 · 228 阅读 · 0 评论