#include #include #include int main(void) { int i,ok,ng,r1,r2,r3; srand(1225); // 「乱数の種」を固定値で指定 srand(time(NULL)); ok=0; ng=0; for(i=0;i<100000;i++) { r1=rand() % 6 + 1 ; // r1=1〜6 r2=rand() % 6 + 1 ; // r2=1〜6 r3=rand() % 6 + 1 ; // r2=1〜6 if(r1+r2+r3<=10) { ok++; } else { ng++; } } printf("OK:%d 回 NG:%d 回 OKの率:%12.8f %%\n", ok,ng,(100.0*ok)/(ok+ng)); return 0; }