#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIDES 6
int saikoro(void) {
return (rand() % SIDES
) + 1; }
int main(void) {
int i, roll1, roll2;
int histogram[2 * SIDES + 1];
for (i = 0; i <= 2 * SIDES; i++) {
histogram[i] = 0;
}
for (i = 0; i < 100000; i++) {
roll1 = saikoro();
roll2 = saikoro();
int sum = roll1 + roll2;
histogram[sum]++;
}
for (i = 2; i <= 12; i++) {
printf("%d\t%d\n", i
, histogram
[i
]); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCiNkZWZpbmUgU0lERVMgNiAgCgppbnQgc2Fpa29ybyh2b2lkKSB7CiAgICByZXR1cm4gKHJhbmQoKSAlIFNJREVTKSArIDE7ICAKfQoKaW50IG1haW4odm9pZCkgewogICAgaW50IGksIHJvbGwxLCByb2xsMjsKICAgIGludCBoaXN0b2dyYW1bMiAqIFNJREVTICsgMV07ICAKCiAgICBmb3IgKGkgPSAwOyBpIDw9IDIgKiBTSURFUzsgaSsrKSB7CiAgICAgICAgaGlzdG9ncmFtW2ldID0gMDsKICAgIH0KCiAgICBzcmFuZCh0aW1lKE5VTEwpKTsKCiAgICBmb3IgKGkgPSAwOyBpIDwgMTAwMDAwOyBpKyspIHsKICAgICAgICByb2xsMSA9IHNhaWtvcm8oKTsgIAogICAgICAgIHJvbGwyID0gc2Fpa29ybygpOyAgCiAgICAgICAgaW50IHN1bSA9IHJvbGwxICsgcm9sbDI7ICAKICAgICAgICBoaXN0b2dyYW1bc3VtXSsrOyAgCiAgICB9CgogICAgcHJpbnRmKCLlkoxcdOmgu+W6plxuIik7CiAgICBmb3IgKGkgPSAyOyBpIDw9IDEyOyBpKyspIHsKICAgICAgICBwcmludGYoIiVkXHQlZFxuIiwgaSwgaGlzdG9ncmFtW2ldKTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=