java-面试
尽是他乡之客
这个作者很懒,什么都没留下…
展开
-
两个线程轮流数数
两个线程交替数数 面试3 两个线程交替数数 import java.util.*; public class DoubleThread { public static void main(String[] args) throws InterruptedException { MyThread task = new MyThread(); //开启两个线程 Thread t1 = new Thread(task, "斯嘉丽约翰孙");原创 2021-07-24 19:47:18 · 297 阅读 · 0 评论 -
无序数组变成有序数组并且去重
无序数组变成有序数组并且去重 面试2:用代码实现无序数组变成有序数组并且去重 例如:{5, 6, 8, 9, 6, 5, 4, 9, 8, 7} 结果:[4, 5, 6, 7, 8, 9] import java.util.*; public class Interview{ public static void main(String[] args) { int[] strs = {5, 6, 8, 9, 6, 5, 4, 9, 8, 7}; //对数组进行排序原创 2021-07-24 19:39:06 · 843 阅读 · 0 评论 -
约瑟夫环-变种
约瑟夫环-变种 面试1:100个人围坐一圈(编号1-100),根据读入的数字n,从1号开始遍历,第n个人出圈,然后第(n+1)个人编号为1,继续遍历,直到圈内只剩n个人为止。 import java.util.*; public class Od { public static void main(String[] args) { //读入一个数字 Scanner in = new Scanner(System.in); int num = in原创 2021-06-15 17:23:29 · 257 阅读 · 1 评论