求一组数组各个元素的和*

package com.chongrui.test;

/*
*求一组数组各个元素的和*
* */

import java.util.Scanner;
public class test {

public static void main(String[] args) {
int[] num = {18,12,344,4,5,6,7,8,9,10};//创建并初始化一维数组num

System.out.println("输出一维数组");
for(int i=0;i<num.length;i++){//num.lenght条件语句

System.out.println(num[i]+" ");//数据元素下标等9的话,输出等号

int min = num[0];
for(int j=0;j<num.length-1;j++){//通过for循环遍历数组
if(min>num[j+1]){
min=num[j+1];


}

}
System.out.println("数组元素的最小"+min);
}




}
}

输出一维数组
18
数组元素的最小4
12
数组元素的最小4
344
数组元素的最小4
4
数组元素的最小4
5
数组元素的最小4
6
数组元素的最小4
7
数组元素的最小4
8
数组元素的最小4
9
数组元素的最小4
10
数组元素的最小4

原文地址:https://www.cnblogs.com/tantanba/p/6287189.html