我自己做的沒有報錯,但是越界怎么解決
package wvw;
import java.util.Arrays;
public class HelloWord {
?public static void main(String[] args) {
??int scores[] = {89,-23,64,91,119,52,73};
??HelloWord A = new HelloWord();
??System.out.println("成績前三有:");
??A.top3(scores);
??
??/*Arrays.sort(scores);
??for(int i = scores.length-1;i >=0;i--) {
???? System.out.print(scores[i] + " ");*/
???
?}
??
??
??public void top3(int []scores) {
???Arrays.sort(scores);
???int mun = 0;
???for(int i = scores.length-1;i >=0;i++) {
????if(0 <= scores[i] && scores[i] <= 100) {
?????System.out.print(scores + " ");
????}else{
?????continue;
????}
????
????while(mun < 3) {
?????System.out.print(scores[i]);
?????mun++;
????}
???}
???
??}???
?
??
?
?
}
2020-01-07
for循環(huán)里面的循環(huán)變量i應(yīng)該是遞減,你寫成i++了
2020-01-09
失誤哈哈