循环赛排序
小组搞个台球比赛,什么都写代码实现真是个好习惯:
var players = [ 'Lion', 'Miles', 'Mark', 'Purk', 'Kevin', 'Collen', 'Victor'];var playlist = [];for (var i = 0; i < players.length; i++) { for (var j = i + 1; j < players.length; j++) { playlist.push(players[i] + ' -- ' + players[j]) }}playlist.sort(function() { return Math.random() > 0.5? - 1: 1;});for (var i =0; i
0. Kevin -- Collen1. Kevin -- Victor2. Miles -- Victor3. Mark -- Purk4. Lion -- Mark5. Lion -- Victor6. Collen -- Victor7. Mark -- Victor8. Miles -- Collen9. Miles -- Mark10. Mark -- Collen11. Lion -- Kevin12. Purk -- Victor13. Miles -- Kevin14. Purk -- Kevin15. Purk -- Collen16. Miles -- Purk17. Mark -- Kevin18. Lion -- Collen19. Lion -- Purk20. Lion -- Miles[Finished in 0.2s]