物件陣列練習題

2021-10-09 01:37:16 字數 1163 閱讀 5248

生成隨機數:math.random(),返回值型別double;

四捨五入取整:math.round(double d),返回值型別long。

public

class

studenttest

} system.out.

println

("***********************************");

//問題二:使用氣泡排序按學生成績排序,並遍歷所有學生資訊

for(

int i =

0;i < s1.length -

1;i++)}

}for

(int i =

0;i < s1.length;i++)}

}class

student

}

改進之後的程式

public

class

studenttest1

//問題一:列印出3年級(state值為3)的學生資訊。

studenttest1 stu =

newstudenttest1()

; stu.

print

(s1)

; stu.

searchstate

(s1,3)

; stu.

sort

(s1)

; stu.

print

(s1)

;//問題二:使用氣泡排序按學生成績排序,並遍歷所有學生資訊

}//遍歷利student1陣列的操作

public

void

print

(student1[

] s1)

}//列印某年級的學生資訊

public

void

searchstate

(student1[

] s1,

int state)}}

//排序

public

void

sort

(student1[

] s1)}}

}}class

student1

}

陣列練習題

2 隨機生成乙個五位以內的數,然後輸出該數共有多少位,每位分別是什麼 3 開發乙個標題為 flipflop 的遊戲應用程式。它從1計數到100,遇到3的倍數就替換為單詞 flip 5的倍數就替換為單詞 flop 既為3的倍數又為5的倍數則替換為單詞 flipflop 5 生成13位條形碼 ean 1...

物件導向練習題

一 讀程式 1 寫出下列 的執行結果 class fatherclass public class test extends fatherclass public static void main string args 結果 fatherclass create fatherclass creat...

物件導向練習題

class myyear object definit self self.year int input 請輸入年份 def show season self for i in range 1,13 if i in 12,1,2 print i,冬季 elif i in 3,4,5 print i,...