精華區beta NTUBIME96-HW 關於我們 聯絡資訊
#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