#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int coin();

int main() {
    int i, head=0, tail=0;
    srand((unsigned)time(NULL));
   
    for(i=0; i<10; i++) {
       if(coin()==0) {
            head++; // 앞면
       }
       else {
            tail++;
       }
    }
    printf("앞면 : %d\n", head);
    printf("뒷면 : %d\n", tail);
       
    return 0;
}

int coin() {
   int t = rand() % 2;
   if(t == 0) {
        return 0; // 앞면
   }
   else {
        return 1; // 뒷면
   }
}

+ Recent posts