本帖最後由 許逸瑋 於 2012-2-11 18:11 編輯
- #include<iostream> //當用到標準輸入與輸出時,需插入此標題檔
- #include<cstdlib> //當用到亂數函數時,需插入此標題檔
- #include<ctime> //當用到時間函數時,需插入此標題檔
- using namespace std;
- int main()
- {
- int a, b, c;
- int run=0;
- cout<<"~~~Money!!! come and go@@~~~"<<endl;
- cout<<"There are the prise description below-3-"<<endl;
- cout<<"if one 7 shows up~"<<"money X2!!"<<endl;
- cout<<"if two 7 shows up~~"<<"money X10!!!"<<endl;
- cout<<"if three 7 shows up~~~"<<"money X100!!!!"<<endl;
- cout<<"this test is going to count how much times does it take to get 777"<<endl;
- system("pause");
- srand(time(NULL));
- while(true)
- {
- run++;
- a=rand()%10;
- b=rand()%10;
- c=rand()%10;
- cout<<a<<""<<b<<""<<c<<endl;
- if(a==7 && b==7 && c==7)
- {
- break;
-
- }
- }
- cout<<"it runs"<<run<<"times"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |