public class newSolut { static int leIndex = 1; static boolean[] hasReceive = new boolean[10 + 1 + 1]; static int[] nums = { 2, 1, 4, 5, 7, 3, 9, 8, 6, 10 }; public static void main(String[] args) { for (int i = 0; i < nums.length; i++) { System.out.println("现在消息流是:" + nums[i]); receive(nums[i]); } } public static void receive(int num) { if (num == leIndex) { if (hasReceive[leIndex] == false) { System.out.println(leIndex); hasReceive[leIndex] = true; leIndex++; while (hasReceive[leIndex] == true) { System.out.println(leIndex); leIndex++; } } } else { hasReceive[num] = true; } } }
点赞 3

相关推荐

StephenZ_:我9月份找的第一段实习也是遇到这种骗子公司了,问他后端有多少人和我说7个正职,进去一看只有一个后端剩下的都是产品前端算法(没错甚至还有算法)。还是某制造业中大厂,我离职的时候还阴阳怪气我
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务