[解答] 計程上機考Q10

看板NTUBIME96-HW作者 (我 累 了)時間22年前 (2003/12/06 00:49), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
#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
文章代碼(AID): #_qBSBKK (NTUBIME96-HW)