java练习:找最大的数

2019年2月16日20:32:43 发表评论 1,117 views
/**
 * Created by xabcd on 2019/2/16.
 */
public class java_largest
{
    public static void main(String args[])
    {
        int arr[] = {23,56,88,92,45,12,11,15};
        int max = largest(arr);
        System.out.println("最大的数字是"+max);
    }
    public static int largest(int arr[])
    {
        int tem=0;
        for (int i = 0;i<arr.length;i++){
            if (arr[i]>tem){
                tem = arr[i];
            }

        }
        return tem;
    }
}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: