demo

public class SL4 {
	public boolean a(int[] q) {
		boolean e = false;
		int w = 0;
		// q=input.nextInt();
		for (int i = 0; i < q.length; i++) {
			if (w < q[i]) {
				w = q[i];
				e = true;
				// break;
			}
		}
		System.out.println("最大值是" + w);
		return e;

	}

}

 

public class SL41 {

	public boolean a(int[] d) {// 数组类型就要声明一个数组类型的参数
		boolean f = false;
		double zong = 0.0;
		for (int i = 0; i < d.length; i++) {
			zong += d[i];
		}
		System.out.println("平均分是" + (zong / 5));
		return f;
	}
}

 

public class SL42 {

	public boolean d(int[] n) {
		boolean g = false;
		int xiao = n[0];
		for (int i = 0; i < n.length; i++) {
			if (xiao > n[i]) {
				xiao = n[i];
			}
		}
		System.out.println("最小值" + xiao);
		return g;

	}
}

 

import java.util.Scanner;

public class SJ42 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		SL4 a = new SL4();
		SL41 b = new SL41();
		SL42 c = new SL42();
		int[] shu = new int[5]; // 数组类型就要声明一个数组类型
		System.out.println("请输入五个数:");
		for (int i = 0; i < 5; i++) {// 输入五遍的循环
			shu[i] = input.nextInt();
		}
		a.a(shu);
		b.a(shu);
		c.d(shu);
	}

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值