- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int player,t,allt,a=0,pat[]= {};
- string name[]= {};
- srand(time(NULL));
- cout<<" 超級金頭腦"<<endl<<endl;
- cout<<"有幾位挑戰者?";
- cin>>player;
- for(int r=0; r<=player-1; r++)
- {
- cout<<"第"<<r+1<<"位挑戰者您好,請問您的大名:";
- cin>>name[r];
- _sleep(500);
- system("cls");
- cout<<"請第"<<r+1<<"位挑戰者就位";
- _sleep(500);
- system("cls");
- t=clock();
- allt=clock();
- while(a<3)
- {
- int q1=rand()%48+51,q2=rand()%48+51,a1;
- cout<<q1<<"+"<<q2<<"=";
- cin>>a1;
- if(a1==q1+q2)
- {
- cout<<"你答對了,總共花費"<<clock()-t<<"毫秒"<<endl;
- a++;
- }
- else
- cout<<"你答錯了,總共花費"<<clock()-t<<"毫秒"<<endl;
- t=clock();
- }
- cout<<name[0]<<"總共用了"<<allt<<"毫秒";
- pat[r]=allt;
- a=0;
- }
- return 0;
- }
複製代碼 |