求数组中个位数不是7且不是7的倍数的累加和
作者:互联网
package com.itheima.demo01;
import java.util.Scanner;
public class Bug04 {
public static void main(String[] args) {
int arr[]=new int[10];
Scanner scanner=new Scanner(System.in);
for (int i = 0; i <10 ; i++) {
System.out.println("请输入第"+(i+1)+"个数:");
int num = scanner.nextInt();
arr[i]=num;
//System.out.println(num);
}
int sum = getSum(arr);
System.out.println(sum);
}
public static int getSum(int arr[]){
int sum=0;
for (int i = 0; i < arr.length; i++) {
int num=arr[i];
if (num%2==0 && num/10!=7){
sum+=num;
}
}
return sum;
}
}
标签:arr,int,个位数,System,累加,num,数组,sum,out 来源: https://www.cnblogs.com/lvtiantian/p/14724704.html