永发信息网

关于java 谢谢了 下面这段代码哪错了 提示是第26行 Arrays cannot be resolved

答案:3  悬赏:20  手机版
解决时间 2021-02-18 21:49
  • 提问者网友:沉默的哀伤
  • 2021-02-17 23:02
public class FirstSample {


public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.print("How many numbers doyou need to draw?");
int k=in.nextInt();
System.out.print("What is the highest number you can draw?");
int n=in.nextInt();
int[] numbers=new int[n];
for(int i=0;i numbers[i]=i+1;
int []result=new int [k];
for(int i=0;i {int r=(int)(Math.random()*n);
result[i]=numbers[r];
numbers[r]=numbers[n-1];
n--;
}
Arrays.sort(result);
System.out.println("Bet the following combination,It'll make you rich!");
for(int r:result)
System.out.println(r);
}

}
最佳答案
  • 五星知识达人网友:过活
  • 2021-02-17 23:24
你的代码引入包不全,是你没有复制过来的吧
加入了引入包,运行正常,没有你说的问题;
不知道你这样做要做什么

另附言:代码风格有待提高;
for(int i=0;i
全部回答
  • 1楼网友:风格不统一
  • 2021-02-18 01:25
你把你的题目弄出来还好一点, 看你的逻辑, 真是蛋疼。。。
  • 2楼网友:神鬼未生
  • 2021-02-18 01:03
//我的能运行啊 我只加了个import java.util.*; import java.util.*; public class FirstSample { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); System.out.print("How many numbers doyou need to draw?"); int k=in.nextInt(); System.out.print("What is the highest number you can draw
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯