第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

4 回答

import?java.util.Arrays;
public?class?HelloWorld?{
?????
????public?static?void?main(String[]?args)?{
????HelloWorld?hello?=?new?HelloWorld();
????int[]?scores?={89,-23,64,91,119,52,73};
????Arrays.sort(scores);????
????System.out.println("考試成績的前三名為:");????
????hello.getScores(scores);
????}
????
????public?void?getScores(int[]?scores){
????????int?count?=?0;
????????for(int?i=scores.length-1;i>=0;i--){
????????????if(scores[i]<=100?&&?scores[i]?>=0?&&?count?<?3){
????????????????System.out.println(scores[i]);
????????????????count?+=?1;
????????????}??????????
????????}
????}
}

為什么樓主要自己定義方法排序呢?有sort方法啊。會簡潔不少。

1 回復(fù) 有任何疑惑可以回復(fù)我~

a=3;

并不是a就是3,而是a指向3

所以

int a,b;

a=a+b;

b=a-b;

a=a-b;

這樣可以交換這兩個數(shù)...

0 回復(fù) 有任何疑惑可以回復(fù)我~

package com.rui.text;


public class JavaDemoTest {
?? ?

??? public static void main(String[] args) {
?? ??? ?JavaDemoTest hello=new JavaDemoTest();
??????? int []scores={89,-23,64,91,119,52,73};
?? ?
??????? hello.get(scores);? ?
??? }

??? public void get(int scores[]){
?? ??? ?for (int i = 0; i < scores.length; i++) {
?? ??? ??? ?if (scores[i]>100 || scores[i]<0) scores[i]=0;
?? ??? ?}
????? for (int i = 0; i < scores.length; i++) {
?? ??? ?for (int j = 0; j < scores.length-1-i; j++) {
?? ??? ??? ?if(scores[j]<scores[j+1]){
?? ??? ??? ??? ?//交換位置
?? ??? ??? ??? ?scores[j]=scores[j]+scores[j+1];
?? ??? ??? ??? ?scores[j+1]=scores[j]-scores[j+1];
?? ??? ??? ??? ?scores[j]=scores[j]-scores[j+1];
?? ??? ??? ?}
?? ??? ?}
?? ?}?? ?
??? ?
????? System.out.println("");
????? //System.out.println(scores[t-1]+"\n"+scores[t-2]+"\n"+scores[t-3]);
????? System.out.println(scores[0]+"\n"+scores[1]+"\n"+scores[2]);
?
??? }
}



0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

chen7841835 提問者

scores[j]=scores[j]+scores[j+1]; scores[j+1]=scores[j]-scores[j+1]; scores[j]=scores[j]-scores[j+1]; 這個是什么意思?為什么要前后兩個數(shù)相加賦值給前一個數(shù)呢
2015-03-26 回復(fù) 有任何疑惑可以回復(fù)我~

你都沒判斷 ,?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

chen7841835 提問者

if(scores[i]>0&&scores[i]<100)這個不算嗎
2015-03-26 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為什么負數(shù)的23會輸出呢

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號