為什么不能出現成績 只出現了“考試前三名成績” 求大神解答
import java.util.Arrays;
public class HelloWorld {
???
??? //完成 main 方法
??? public static void main(String[] args) {
????? int[] scores={89,-23,64,91,119,52,73} ;
????? System.out.println("考試成績前三名為:");
????? HelloWorld hello=new HelloWorld();
????? hello.show(scores);
??? }
???? public void show(int[] scores){
???????? Arrays.sort(scores);
???????? int num=0;
???????? for(int i=scores.length-1;i>=0;i--){
????????????
????????? if (scores[i]<100||scores[i]>0){
????????????? continue;?
????????? }
????????? num++;
????????? if(num>3){
????????????? break;
????????? }
??????? System.out.println(Arrays.toString(scores));?
???? }
????
??? }
???
??? }//定義方法完成成績排序并輸出前三名的功能
???
???
???
???
?
2016-05-16
if 條件判斷前三名成績 了? num 》 3? 就跳出循環? 進行打印? 所以只能 顯示前三明成績
2016-05-06
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? int scores = { 89, -23, 64, 91, 119, 52, 73 };
? ? ? ? System.out.println("考試成績的前三名為:");
? ? ? ? HelloWorld hello = new HelloWorld ();
? ? ? ? hello.showTop(scores);
? ? ? ??
? ? ? ??
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void shouTop3(int[] score){
? ? ? ? Arrays.sort(scores);
? ? ? ? int num = 0;
? ? ? ? for (int i = scores.length = 1; i >=0; i--){
? ? ? ? ? ? if (scores[i] < 0) || scores[i] > 100) {
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? } numu++;
? ? ? ? ? ? if (num > 3){
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? ? ? System.out.println(scores[1]);
? ? ? ? }
? ? }
?} ??
2016-05-06
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? int scores = { 89, -23, 64, 91, 119, 52, 73 };
? ? ? ? System.out.println("考試成績的前三名為:");
? ? ? ? HelloWorld hello = new HelloWorld ();
? ? ? ? hello.showTop(scores);
? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void shouTop3(int[] score){
? ? ? ? Arrays.sort(scores);
? ? ? ? int num = 0;
? ? ? ? for (int i = scores.length = 1; i >=0; i--){
? ? ? ? ? ? if (scores[i] < 0) || scores[i] > 100) {
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? } numu++;
? ? ? ? ? ? if (num > 3){
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? ? ? System.out.println(scores[1]);
? ? ? ? }
? ? }
? ??