嗨,我試圖格式化並創建此數組:陣列格式化方法
Person[] persons = { person1, person2, person3, person4, person5, person6, person7, person8, person9, person10 };
// The aim is to form an array of the 5 strongest people's indices above
int[] arrayOfStrongestPeopleIndices = new int[5];
for (int index = 0; index < 10; index++){
int strength = persons[index].strength;
for (int str : arrayOfStrongestPeopleIndices){
//something @ here ?
}
}
所以我到10人試圖循環,以及陣列arrayOfStrongestPeopleIndices
應該是最強的人指數爲5(以最強爲了最弱的,即array[0]
是最強的人指數開出5,而array[4]
是最弱的5)
的問題:我如何返回格式化arrayOfStrongestPeopleIndices的規定?
請張貼可執行代碼,因爲人員數組大小我們無法猜測。 – RamPrakash
你對這篇文章有任何問題嗎? –
編輯過的主帖,應該比較容易看懂 –