
展开全部
import java.util.Scanner;
public class TestOld {
public static void main(String[] args) {
int[] a = new int[100];
int count = 0, hcount = 0;
for(int i = 0; i < a.length; i++){
a[i] = (int) (99 * Math.random() + 1);
}
System.out.println("输出随机生成的数组: ");
for(int t : a){
System.out.print(t + " ");
hcount++;
if(hcount == 10){
System.out.println();
hcount = 0;
}
}
Scanner sc = new Scanner(System.in);
System.out.println("输入一个整数: ");
int temp = sc.nextInt();
for(int i = 0; i < a.length; i++){
if(temp == a[i]){
count++;
}
}
if(count == 0){
System.out.println("该数不存在这个数组中");
}else{
System.out.println("该数在数组中出现[" + count + "]次");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询