importjava.util.Scanner;importjava.util.ArrayList;publicclassMain{publicstaticvoidmain(String[] args){Scanner sc =newScanner(System.in);while(sc.hasNextInt()){int n = sc.nextInt();if(n==0){break;}ArrayList<Integer> nums =newArrayList<Integer>();int sum =0;for(int i=0;i<n;i++){
nums.add(sc.nextInt());
sum += nums.get(i);}int h = sum/n;int res =0;for(int i=0;i<n;i++){if(nums.get(i)<h){
res += h-nums.get(i);}}System.out.println(res);System.out.println();}
sc.close();}}
8. 奇怪的信
importjava.util.*;publicclassMain{publicstaticvoidmain(String[] args){Scanner sc =newScanner(System.in);while(sc.hasNextInt()){int n = sc.nextInt();ArrayList<Integer> nums =newArrayList<Integer>();while(n>0){int t = n %10;
nums.add(t);
n /=10;}int res =0;for(int i=0;i<nums.size();i++){if(nums.get(i)%2==0){
res += nums.get(i);}}System.out.println(res);System.out.println();}}}