1.
package sj;
import java.util.*;
public class zy {
public static void main(String[] args) {
int a[] = new int[10];
int sum = 0, max = 0, min = 1000;
System.out.println("请输入分数");
for (int i = 0; i < a.length; i++) {
Scanner input = new Scanner(System.in);
a[i] = input.nextInt();
}
for (int j = 0; j < a.length; j++) {
if (a[j] > max) {
max = a[j];
}
}
for (int x = 0; x < a.length; x++) {
if (a[x] < min) {
min = a[x];
}
}
for (int y = 0; y < a.length; y++) {
sum += a[y];
}
System.out.println("平均分为" + (sum - max - min) / 8.0);
}
}
2.
package sj;
import java.util.Random;
public class zy {
public static void main(String[] args) {
// TODO Auto-generated method stubint
int[] a = new int[10];
Random r=new Random();
for (int i = 0; i < a.length; i++) {
a[i]=r.nextInt(100);
}
int t;
for (int i = 0; i < a.length - 1; i++) {
for (int j = 0; j < a.length-1-i; j++) {
if (a[j + 1] > a[j]) {
t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
for (int i : a) {
System.out.println(i);
}
}
}
3.
package sj;
import java.util.Random;
public class zy {
public static void main(String[] args) {
Random random = new Random();
int a=0;
int[] arr = new int[7];
arr[0] = random.nextInt(35);
for(int i=1;i<arr.length;i++) {
arr[i] = random.nextInt(35);
if(arr[i]==arr[i-1]) {
a=1;
i--;
continue;
}
}
System.out.println("七个数:");
for(int i =0;i<arr.length;i++) {
System.out.print(arr[i]+" ");
}
}
}
4.
package sj;
public class zy{
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a = new int[]{44,33,22,11,55,66,77,88,99,67};
int max=a[0];
int min=a[0];
int js=0;
int os=0;
for (int i = 1; i <a.length ; i++) {
if (a[i]>max){
max=a[i];
}
}
for (int j = 1; j <a.length ; j++) {
if (a[j]<min){
min=a[j];
}
}
for (int k = 0; k< a.length; k++) {
if (a[k]%2==0){
os+=1;
}else {
js+=1;
}
}
System.out.println("最大值为"+max+"最小值为"+min+"偶数有"+os+"个"+"奇数有"+js+"个");
}
}