Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int alea(int min, int max) {
- return rand() % (max - min + 1) + min;
- }
- int pairImpair(int n) {
- if (n % 2 == 0) {
- return 0;
- } else {
- return 1;
- }
- }
- int main() {
- int tab[25];
- int i;
- int nbPair = 0;
- srand(time(NULL));
- // tire 25 nombres aléatoires
- for (i = 0; i < 25; i++) {
- tab[i] = alea(10, 49);
- }
- // compte le nombre de pairs
- for (i = 0; i < 25; i++) {
- if (pairImpair(tab[i]) == 0) {
- nbPair++;
- }
- }
- if (nbPair > 12) {
- printf("FACE\n");
- } else {
- printf("PILE\n");
- }
- // affiche les valeurs du tableau
- for (i = 0; i < 25; i++) {
- printf("%d ", tab[i]);
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement