1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* un nombre aleatoire dans [min, max] */
int alea(int min, int max);
int main()
{
/* déclarations */
int i;
int rand1, rand2;
srand(time(NULL));
/* boucle pour 2 tirages, */
for (i=0;i<2;++i)
{
rand1 = alea(1, 49);
rand2 = alea(1, 49);
/* affichage */
printf ("**************************************** TIRAGE*********************************************")
printf ("No %d:\t1 <= %d <= 49\t1 <= %d <= 49\n", i+1, rand1, rand2);
printf ("**************************************** **************************************************")
}
return 0;
}
/* un nombre aleatoire dans [min, max] */
int alea(int min, int max) {
int plage = max-min+1;
return (rand () % plage) + min;
} |