ระดับกลาง
4 ตุลาคม 2569หาบั๊กให้เจอ: Android
โค้ดหนึ่งชิ้น หาบั๊กให้เจอ หรือพิสูจน์ว่าไม่มีบั๊ก
kotlin
1fun sortAndGetTop3(scores: MutableList<Int>): List<Int> {
2 scores.sort()
3 scores.reverse()
4 return scores.take(3)
5}
6
7fun displayResults(scores: MutableList<Int>) {
8 println("Original: $scores")
9 val top3 = sortAndGetTop3(scores)
10 println("Top 3: $top3")
11 println("All scores: $scores")
12}คลิกบรรทัดที่เป็นต้นเหตุของปัญหา
คำตัดสินของคุณ
วันละหนึ่งครั้ง คำตอบจะแสดงทันทีหลังจากนั้น
รักษาสถิติต่อเนื่องของคุณ
สร้างบัญชีเพื่อเก็บสถิติต่อเนื่องและติดตามความคืบหน้า