一、题目链接
http://noi.openjudge.cn/ch0109/07/
二、解题思路
三、实施步骤
四、Java程序
import java.util.Scanner;
public class Main {
public int getMax(int[] nums) {
int n = nums.length;
int ans = nums[0];
for (int i = 1; i < n; i++) {
ans = (ans < nums[i] ? nums[i] : ans);
}
return ans;
}
public int sumExceptMax(int[] nums) {
int maxValue = getMax(nums);
int ans = 0;
for (int e : nums) {
ans = (e != maxValue ? ans + e : ans);
}
return ans;
}
public static void main(String[] args) {
Main test = new Main();
Scanner input = new Scanner(System.in);
int N = input.nextInt();
int[] nums = new int[N];
for (int i = 0; i < nums.length; i++) {
nums[i] = input.nextInt();
}
System.out.print(test.sumExceptMax(nums));
}
}