掷骰子20次 统计结果

来源:互联网 发布:sql和core data 编辑:程序博客网 时间:2024/05/23 01:12
#include <stdio.h>#include <stdlib.h>/* main */int main(void){    int x;    int i;    /* Throw the dice 20 times */    for (i=1; i<=20; i++)    {        /* use the function rand() to simulation the random result */        x= 1 + rand() % 6; /* 6 is the zoom factor, make sure the result between 0~5*/        printf("%d", x);        /* print 5 results every line */        if (i % 5 == 0)        {            printf("\n");        }    }    return 0;}


0 0