看板 NTUBIME101HW 關於我們 聯絡資訊
#include <iostream> #include <iomanip> #include <ctime> using namespace std; int loto_number(); int main() { srand(time(NULL)); int loto[7]; for(int i=0;i<7;i++) { loto[i] = loto_number(); for(int j=0;j<i;j++) { if(loto[i]==loto[j]) { loto[i] = loto_number(); j = 0; } } if(i==6) cout << "特別號:"; cout << setw(2) << loto[i] << " "; } system("pause"); return 0; } int loto_number() { int number = rand()%42+1; return number; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.7.59
ck940560:做個\b的動畫會比較好@@ 單純花俏路線 11/18 14:39
sb0917:這是給大家看的標準版程式碼啦~______~ 11/18 20:43
※ 編輯: sb0917 來自: 140.112.7.59 (11/19 17:27)