輸出來(lái)是亂碼 哪里出問(wèn)題了
import java.util.Arrays;
public class HelloWorld {
???
??? //完成 main 方法
??? public static void main(String[] args) {
??????? HelloWorld hello = new HelloWorld();
??? int[] scores={ 89 , -23 , 64 , 91 , 119 , 52 , 73};??
??? Arrays.sort(scores);
??? int[] b=hello.pai(scores);
??? System.out.println(b);???
??? }
???
??? //定義方法完成成績(jī)排序并輸出前三名的功能
??? public int[] pai(int[] scores){
??????? int j=0;
??????? int[] qian=new int[3];
??????? for(int i = scores.length - 1; i >= 0; i--){
??????????? if(scores[i]<0||scores[i]>100)
??????????????? continue ;
??????????? else{if(j<3){
??????????????????? qian[j]=scores[i];
??????????????????? j++;}
??????? }
??????? }
??????? return qian;
???????????
??? }??
???
}
2015-11-27
你返回的qian是一個(gè)數(shù)組。怎么能直接printf一個(gè)數(shù)組呢? ? ?
把main函數(shù)下最后一行? System.out.println(b); ? 換成下面代碼就哦了
? for(int i=0;i<3;i++)
? System.out.println(b[i]); ??
2015-11-27
好亂啊。。。。看的感覺(jué)自己啥也沒(méi)學(xué)