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

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

大神指點一下

package com.lianxi;


import java.util.Arrays;


public class Biancheng {

public static void main(String[] args) {

Biancheng hello=new Biancheng();

int[] nums=hello.print(7);

Arrays.sort(nums);

System.out.println("考試成績的前三名為:");

System.out.println(Arrays.toString(nums));

System.out.println(nums[6]);

System.out.println(nums[5]);

System.out.println(nums[4]);

}

? ? ?public ?int[] ?print(int length) {?

? ? int[] scores={89,-23,64,91,119,52,73};

? ? int[] nums=new int[length];

? ? ?

? ? for(int i=0;i<scores.length;i++){?

? ? if(0<scores[i]&&scores[i]<100){

? ? int j=0;

nums[j]=scores[i];

j++;

? ? }

? ? }

? ? return nums;

? ? ?}

? ? ?

? ??

}

哪里不對了?

正在回答

3 回答

你寫的亂了,建議你研究一下這個http://img1.sycdn.imooc.com//5934bf250001149605260825.jpg

0 回復 有任何疑惑可以回復我~
#1

慕斯1379455 提問者

非常感謝!
2017-06-05 回復 有任何疑惑可以回復我~
#2

慕斯1379455 提問者

這個挺好!謝謝!
2017-06-05 回復 有任何疑惑可以回復我~


import java.util.Arrays;


public class Biancheng {

public static void main(String[] args) {

Biancheng hello=new Biancheng();

int[] nums=hello.print(7);

Arrays.sort(nums);

System.out.println("考試成績的前三名為:");

// System.out.println(Arrays.toString(nums));

System.out.println(nums[6]);

System.out.println(nums[5]);

System.out.println(nums[4]);

}

? ? ?public ?int[] ?print(int length) {?

? ? int[] scores={89,-23,64,91,119,52,73};

? ? int[] nums=new int[length];?

? ? for(int i=0;i<scores.length;i++){?

? ? if(scores[i]<0||scores[i]>100){

? ? continue;

? ? }

nums[i]=scores[i];

? ?

? ? ? ? } return nums;

? ?

? ? ?}

? ? ?

? ??

}

調(diào)好了,不一定非得用給定的答案!

0 回復 有任何疑惑可以回復我~
#1

慕尼黑7647582

這只是我寫的一個答案,實現(xiàn)的代碼有很多種,每個人的想法也都不一樣。把思路想好了,代碼就容易寫了。建議在eclipse中敲代碼,可以幫你分析代碼的語法錯誤
2017-06-04 回復 有任何疑惑可以回復我~
#2

慕斯1379455 提問者 回復 慕尼黑7647582

是的,我每次都會在eclipse中寫一遍沒錯誤了,才會復制在課程的題目中提交
2017-06-04 回復 有任何疑惑可以回復我~

代碼有些混亂,有些代碼邏輯不夠明確。寫代碼時先要縷清思路。給你個代碼參考下

????????int?scores[]=new?int[]{89,-23,64,91,119,52,73};
????????int?count=0;//統(tǒng)計輸出個數(shù)
????????Arrays.sort(scores);//升序排序
????????for(int?i=scores.length-1;i>=0;i--){//從成績最大的開始循環(huán)
????????????if(scores[i]<0||scores[i]>100)?continue;//不符合范圍的分數(shù)不能進入循環(huán)
????????????System.out.println(scores[i]);//輸出成績
????????????count++;
????????????if(count>2)?break;//輸出3個成績后終止循環(huán)
????????}


0 回復 有任何疑惑可以回復我~
#1

慕斯1379455 提問者

你這是給定的答案
2017-06-04 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Java入門第一季(IDEA工具)升級版
  • 參與學習       1167361    人
  • 解答問題       18728    個

0基礎萌新入門第一課,從Java環(huán)境搭建、工具使用、基礎語法開始

進入課程

大神指點一下

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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