本帖最後由 曲書辰 於 2019-6-16 11:15 編輯
[code][/code]#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int c[2]={0,0};
int m[6]={0,0,0,0,0,0};
int l[6]={0,0,0,0,0,0};
string f[11]={"","","","","","","","","",""};
int b,d=0,e,sum=0,svg=0,g=0,a=-1;
double c1,c2;
srand(time(NULL));
cout<<"超級金頭腦 1.0v"<<endl;
cout<<"遊戲規則:電腦隨機出題\t看誰能在最短的時間內答對三題"<<endl;
cout<<"請輸入人數:";
cin>>e;
cout<<"準備開始喔"<<"按下enter鍵就開始吧"<<endl;
system("pause");
system("cls");
for(int i=0;i<e;i++)
{
g=0;
g++;
system("cls");
d=0;
cout<<"第"<<i+1<<"位挑戰者你好\t"<<"請輸入你的名子:";
cin>>f;
cout<<f<<"請就位!!!"<<endl;
system("pause");
system("cls");
sum=0;
while(sum<3)
{
svg+=d;
for(int i=0;i<2;i++)
{
c=rand()%4;
}
c1=clock();
cout<<c[0]<<"+"<<c[1]<<"=";
cin>>b;
c2=clock();
d=c2-c1;
if(c[0]+c[1]==b)
{
cout<<"答對了!"<<endl;
cout<<"你用了:"<<d<<endl;
sum++;
}
else
{
cout<<"答錯了!"<<"正確答案是"<<b<<endl;
cout<<"你用了:"<<d<<endl;
}
m=svg;
}
cout<<"你總共用了:"<<svg<<endl;
system("pause");
system("cls");
}
for(int i=0;i<=e;i++)
{
a=-1;
for(int j=0;j<=e;j++)
{
if(m-m[j]<0)
a++;
}
l[a]=m;
}
for(int k=0;k<e;k++)
{
cout<<f[k]<<"\t"<<l[k]<<endl;
}
system("pause");
return 0;
} |