Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function shuffle(array) {
- var counter = array.length, temp, index;
- while (counter > 0) {
- index = Math.floor(Math.random() * counter);
- counter--;
- temp = array[counter];
- array[counter] = array[index];
- array[index] = temp;
- }
- return array;
- }
- var joueur = [];
- var joueurs = parseInt(prompt("Nombre de joueurs"),10);
- for (i = 0 ; i < joueurs ; i++)
- {
- joueur[i] = prompt("Joueur " + (i+1));
- }
- var liste = shuffle(joueur);
- for (i = 0 ; i < joueurs ; i++)
- {
- liste[liste.length + i] = liste[i];
- }
- var tours = joueurs + 1;
- alert("Tours : " + tours);
- for (i = 0 ; i < tours ; i++)
- {
- document.write(1 + ". " + liste[(i+0)%joueurs+1] + "<br />");
- document.write(2 + ". " + liste[(i+1)%joueurs+1] + "<br />");
- document.write(3 + ". " + liste[(i+2)%joueurs+1] + "<br />");
- document.write(4 + ". " + liste[(i+3)%joueurs+1] + "<br />");
- document.write(5 + ". " + liste[(i+4)%joueurs+1] + "<br /><br /><br />");
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement