作者wendychang (我 累 了)
看板NTUBIME96-HW
标题[解答] 计程上机考Q10
时间Sat Dec 6 00:49:19 2003
#include <stdafx.h>
#include <iostream>
using std::cout;
using std::endl;
#include <cstdlib>
#include <ctime>
int main(int argc, char* argv[])
{
int point[ 7 ] = { 0 };
int i;
srand( time ( 0 ) );
for( i = 1; i <= 10000; i++ )
point[ rand() % 6 + 1 ]++;
cout << "模拟掷骰子10000次结果统计如下:" << endl << endl;
for( i = 1; i <= 6; i++ )
cout << i << "点次数:" << point[ i ] << endl;
cout << endl;
return 0;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.174.159.54