package com.fqs.test; public class hello { public static void main(String[] args) { //定义一个数组,存储12345 求和 int []arr={1,2,3,4,5}; int sum=0; for(int i=0;i<arr.length;i++){ sum=sum+arr[i]; } System.out.println("sum:"+sum); } }
能被3整除的数字
package com.fqs.test;
public class hello {
public static void main(String[] args) {
//定义一个数组,存储12345678910 遍历数组 求那几个可以被3除
int []arr={1,2,3,4,5,6,7,8,9,10};
for(int i=1;i<arr.length;i++){
if(arr[i]%3==0){
System.out.println("能整除的数:"+arr[i]);
}
}
}
}
标签:arr,遍历,找能,int,56,数组,整除,public From: https://www.cnblogs.com/haha1988/p/17461464.html