A voir également:
- Fonction random en Javascool
- Fonction random c ✓ - Forum - C++
- Fonction random en c - Conseils pratiques - Langage C
- [Langage C] Générer nombre aléatoire ✓ - Forum - C
- Fonction random excel - Forum - Excel
- Fonction random pascal - Forum - Pascal
2 réponses
KX
- Messages postés
- 16165
- Date d'inscription
- samedi 31 mai 2008
- Statut
- Modérateur
- Dernière intervention
- 23 janvier 2021
Tu peux prendre un nombre aléatoire entre 1 et 15, et faire matcher les différents cas :
1 → -10, 2 → -9, 3 → -7, 4 → -6, 5 → -4... 15 → 9
1 → -10, 2 → -9, 3 → -7, 4 → -6, 5 → -4... 15 → 9
Morgan
Je viens de faire ça, ça marche très bien. Merci beaucoup
r=random(1,14);
switch (r){
case 1:p=-10;
break;
case 2:p=-9;
break;
case 3:p=-7;
break;
case 4:p=-6;
break;
case 5:p=-4;
break;
case 6:p=-3;
break;
case 7:p=-1;
break;
case 8:p=0;
break;
case 9:p=2;
break;
case 10:p=3;
break;
case 11:p=5;
break;
case 12:p=6;
break;
case 13:p=8;
break;
case 14:p=9;
break;
}
r=random(1,14);
switch (r){
case 1:p=-10;
break;
case 2:p=-9;
break;
case 3:p=-7;
break;
case 4:p=-6;
break;
case 5:p=-4;
break;
case 6:p=-3;
break;
case 7:p=-1;
break;
case 8:p=0;
break;
case 9:p=2;
break;
case 10:p=3;
break;
case 11:p=5;
break;
case 12:p=6;
break;
case 13:p=8;
break;
case 14:p=9;
break;
}