//逢7过
for (int i = 0; i <= 1000; i++) {
int g=i%10;
int s=i/10%10;
int b=i/100%10;
if((i%7)!=0&&g!=7&&s!=7&&b!=7)
System.out.println(i);
else
System.out.println("过");
}
//数组求和
int array[]={68,27,95,88,171,996,51,210};
int sum=0;
for (int i = 0; i < array.length; i++) {
int g=array[i]%10;
int s=array[i]/10%10;
if(g!=7&&s!=7&&array[i]%2==0) {
System.out.println(array[i]);
sum+=array[i];
}
}
System.out.println(sum);
//数组收尾交换
//方法一
int array[]=new int[]{19,28,37,46,50,19,19};
for (int i = 0; i < array.length/2; i++) {
int temp=array[i];
array[i]=array[array.length-1-i];
array[array.length-1-i]=temp;
}
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
//方法二
int array[]=new int[]{19,28,37,46,50,19,19};
for (int i = 0,j=array.length-1; i < j; i++,j--) {
int temp=array[i];
array[i]=array[j];
array[j]=temp;
}
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
//输出6个分数
private static void scoreInput(int num,int arr[]) {
Scanner sc=new Scanner(System.in);
for (int i = 0; i < num; i++) {
System.out.println("请输入分数:");
arr[i]=sc.nextInt();
}
}
//查找最高分
private static int maxFind(int[] arrayScore) {
int max=arrayScore[0];
for (int i = 0; i < arrayScore.length; i++) {
if(arrayScore[i]>max)
max= arrayScore[i];
}
System.out.println("最大值为"+max);
return max;
}
//查找最低分
private static int minFind(int[] arrayScore) {
int min=arrayScore[0];
for (int i = 0; i < arrayScore.length; i++) {
if(arrayScore[i]<min)
min= arrayScore[i];
}
System.out.println("最小值为"+min);
return min;
}
//计算最终分值并输出
private static void finalScore(int[] arrayScore, int max, int min) {
int sum=0;
for (int i = 0; i < arrayScore.length; i++) {
sum+= arrayScore[i];
}
sum-= max + min;
System.out.println("选手的成绩是"+sum);
}
public static void main(String[] args){
int arrayScore[]=new int[6];
scoreInput(6,arrayScore);
for (int i = 0; i < arrayScore.length; i++) {
System.out.println("第" + (i+1) + "个分数是:"+arrayScore[i]);
}
int max=maxFind(arrayScore);
int min=minFind(arrayScore);
finalScore(arrayScore, max, min);
}