JAVA第七周上机练习
2021-02-15 20:19
标签:col pac alt 次数 core 最小值 就是 src == 1.有10个评委打分,(去掉一个最高一个最低)求平均分。 2.自学一下Java随机数,生成一个长度为10的随机数组(每个数的范围是0~99),排序后输出 3.制作彩票35选7程序。 (就是1~35随机生成7个不重复的数) 4.定义一个长度为10的int数组,统计数组中的最大值、最小值、以及奇数和偶数的个数 JAVA第七周上机练习 标签:col pac alt 次数 core 最小值 就是 src == 原文地址:https://www.cnblogs.com/jisuanji-04/p/12711975.htmlpackage aa;
import java.util.Scanner;
public class Wyy {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int [] a=new int [10];
int c=0;
for(int i=0;i
package aa;
import java.util.Random;
public class Wyy {
public static void main(String[] args) {
// TODO Auto-generated method stub
int arr[] = new int[10];
Random r = new Random();
for (int i = 0; i ) {
arr[i] = r.nextInt(100);
}
for (int i = 0; i ) {
for (int n = 0; n ) {
if (arr[n] > arr[n + 1]) {
int c = arr[n];
arr[n] = arr[n + 1];
arr[n + 1] = c;
}
}
}
for (int x = 0; x ) {
System.out.print(arr[x] + " ");
}
}
}
package aa;
import java.util.Random;
public class Wyy {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] score = new int[7];
Random r = new Random();
for (int i = 0; i )
{
score[i] = r.nextInt(35) + 1;
}
System.out.println("35选7号码为:");
for (int i = 0; i )
{
System.out.print(score[i]+" ");
}
}
}
package aa;
public class Wyy {
public static void main(String[] args) {
// TODO Auto-generated method stub
int max=0,min=99;
int os=0,js=0;
int []a={99,45,23,66,12,30,65,26,8,44};
for (int i = 0; i ) {
if (a[i] min) {
min = a[i];
}
if (a[i] > max) {
max = a[i];
}
}
for (int i = 0; i ) {
if (a[i]%2==0) {
os++;
}else{
js++;
}
}
System.out.println("偶数出现的次数:" + os);
System.out.println("奇数出现的次数:" + js);
System.out.println("最大值:" + max);
System.out.println("最小值:" + min);
}
}
下一篇:3.K均值算法