首页 > 其他分享 >algrothm_经典[]求最大值最小值

algrothm_经典[]求最大值最小值

时间:2023-03-21 17:02:02浏览次数:37  
标签:algrothm arr Min int Max 最大值 System 最小值 out


class Demo{/*数组获取最值(获取数组中的最大值最小值)*/public static void main(String args[]){ int Max,Min; int [] arr = {2,1,3,5,4}; Max = Min =arr[0]; for(int i =0; i<arr.length;i++){ if(Max < arr[i]){ Max = arr[i]; } if(Min > arr[i]){ Min = arr[i]; } } System.out.println(Max); System.out.println(Min); }}


标签:algrothm,arr,Min,int,Max,最大值,System,最小值,out
From: https://blog.51cto.com/u_16021118/6140562

相关文章