// C4_2.cpp : Defines the entry point for the console application. // 取得亂數值 #include "stdafx.h" #include #include #include #include using namespace std; int main(int argc, char* argv[]) { int i; /* * 設定亂數起始點 */ srand( (unsigned)time( NULL ) ); cout << endl << "顯示原始亂數值 : " << endl; /* 顯示十位數 */ for( i = 0; i < 10;i++ ) printf( " %6d\n", rand() ); cout << endl << "顯示一位數亂數值 : " << endl; /* 顯示一位數 */ for( i = 0; i < 10;i++ ) printf( " %6d\n", rand() % 10); return 0; }