scores专题

[leetcode][DataBase] - 178. Rank Scores with [MySQL]

problem select inn.Score,inn.Rank from (select ss.Score,@row:=@row+1 as Rankfrom (select @row:=0) a,(select Score from Scores group by Score) as ssorder by ss.Score desc) as innright joinScores as

Swift3按顺序只取前五个最高分组成排行榜,sorted array of top 5 scores leaderboard

假设array有5个分数 let array = [98,88,33,22,10] 每次新输入的成绩,如果比最低分高,则取代数列中的某分值的位置 if(newValue!>array[4]){for i in (0..<5){if(newValue!>array[i]){for j in (i+1..<5).reversed(){array[j] = array[j-1]}array[i]