import java.util.Random; public class Lanxi { public static void main(String[] args) { int[] num = new int[10]; int sum = 0; double avg = 0; long amass = 1L; int max = 0; int min = num[0]; Random r = new Random(); for (int i = 0; i < num.length; i++) { num[i] = r.nextInt(100); } System.out.println("数列中10个元素为:"); for (int i = 0; i < num.length; i++) { System.out.print(num[i]+"\t"); } for (int i = 0; i < num.length; i++) { sum += num[i]; amass *= num[i]; if (max < num[i]) { max = num[i]; }else if (min > num[i]) { min = num[i]; } } avg = sum / 10; System.out.println("\n数组元素和为:"+sum+"\t积为:"+amass+"\t平均数为:"+avg+"\t最大数为:"+max+"\t最小数为:"+min); } } 为什么输出不了最小值,一直为0,就在这个上面改 不用重新写
1ãæè·¯
é¦å å©ç¨éæºæ°å½æ°çæ100个éæºæ°ï¼
ç¶åå¨è¿100个æ°ä¸ï¼éè¿æ¯è¾ï¼æ¾åºæ大æ°åæå°æ°ã
2ã代ç å¦ä¸
import java.util.Random;