
算法
MarkandLcg
这个作者很懒,什么都没留下…
展开
-
Java int数据类型数组求最大值、最小值、元素总和
Java int数据类型数组求最大值、最小值、元素总和1.方法一:public class Main { public static void main(String[] args) { int[] num = {1, 9, 2, 6, 5}; //定义一个int数组 int max = Integer.MIN_VALUE; //最大值赋值为最小数(防止数组内的数比max初始值小) int min = Integer.MAX_VALU原创 2021-04-27 00:06:45 · 4060 阅读 · 0 评论 -
Java int数据类型数组降序排列的方法
Java int数组类型数组降序排列的方法前言:使用Java对int数据类型数组降序排列没有C++那样方便但是也是可以简单实现的。方法一:public class Main { public static void main(String[] args) { int[] num = {1, 9, 2, 6, 5}; //定义一个int数组 for(int i = 0; i < num.length; i++) { Sys原创 2021-04-12 20:15:54 · 13113 阅读 · 0 评论 -
Java 二叉搜索树(BST)三种遍历方式的模板
Java 二叉树(BST)三种遍历方式的模板先序遍历if(root == null) { return;}执行操作dfs(root.left);dfs(root.right);中序遍历if(root == null) { return;}dfs(root.left);执行操作dfs(root.right);3.后序遍历if(root == null) { return;}dfs(root.left);dfs(root.right);执行原创 2021-04-13 21:45:11 · 277 阅读 · 0 评论