import java.util.Scanner;
public class score {
/**
* @param args
*/
public static void main(String[] args) {
Scanner reader=new Scanner(System.in);
System.out.println("输入用户个数:");
int score=reader.nextInt();
int score1[]=new int[score];
System.out.println("输入用户成绩:");
for(int i=1;i<=score1.length;i++){
double s=reader.nextDouble();
}
System.out.println("输入查找学生");
int n=reader.nextInt();
if(n==score){
System.out.println("第"+score+"学生成绩是:"+score1[score]);
}
}
}
我执行不到最后一步~最后需要询问用户查询结果
可以了
score1[i] = s;这个什么意思啊
要给数组赋值啊,要不你创建他做什么啊
追问赋值以后在if语句里面没有赋值的s啊。但是少这句就不能查询。有这句就可以查询~这个不太明白。我新手讲解一下吧
追答没有赋值就相当于你只是创建了个数组,里面是空的(默认值是0.0)
double score1[] = new double[score];
然后你查询,肯定查不到啊.
谢谢。!!!感谢!!给你分