- UID
- 2175026
- 熱心
- 121 值
- 嘉獎
- 0 次
- 違規
- 0 次
- 在線時間
- 43 小時
- 經驗
- 67 點
- 積分
- 398
- 精華
- 0
- 最後登錄
- 2016-9-22
- 閱讀權限
- 25
- 註冊時間
- 2014-11-4
- 論壇幣
- 57 幣
- 聯合幣
- 115 枚
- 幸運鑽
- 0 顆
- 招待卷
- 0 點
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
bool StrCmp(char Str1[],char Str2[])
{
bool nReturn = true;
for (int i = 0; i < 15 ; i++)
{
if (Str1[i] != Str2[i])
{
nReturn = false;
}
if (Str2[i] == 0)
{
return true;
}
}
return nReturn;
}
int main()
{
char database[40][15]={"#include","<iostream>","using","namespace","int",
"return", "asm","do","inline","short",
"typeid","auto","double","signed","typenmae",
"break","else","iong","sizeof","union",
"bool","enum","mutable","static","unsigned",
"case","explicit","struct","using","catch",
"extern","new","switch","virtual","char",
"flase","operator","template","void","class",
};
char input[15];
int num,start,end;
srand(time(0));
for (int i=0;i<10;i++)
{
num=rand()%40;
cout<<database[num]<<":\n";
start=time(0);
cin>>input;
end=time(0);
if(StrCmp(database[num],input))
{
cout << "答案正確!" << endl;
}else{
cout << "答案錯誤!" << endl;
};
cout<<"共花"<<end-start<<"秒\n";
}
return 0;
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
bool StrCmp(char Str1[],char Str2[])
{
bool nReturn = true;
for (int i = 0; i < 15 ; i++)
{
if (Str1[i] != Str2[i])
{
nReturn = false;
}
if (Str2[i] == 0)
{
return true;
}
}
return nReturn;
}
int main()
{
char database[40][15]={"#include","<iostream>","using","namespace","int",
"return", "asm","do","inline","short",
"typeid","auto","double","signed","typenmae",
"break","else","iong","sizeof","union",
"bool","enum","mutable","static","unsigned",
"case","explicit","struct","using","catch",
"extern","new","switch","virtual","char",
"flase","operator","template","void","class",
};
char input[15];
int num,start,end;
srand(time(0));
for (int i=0;i<10;i++)
{
num=rand()%40;
cout<<database[num]<<":\n";
start=time(0);
cin>>input;
end=time(0);
if(StrCmp(database[num],input))
{
cout << "答案正確!" << endl;
}else{
cout << "答案錯誤!" << endl;
};
cout<<"共花"<<end-start<<"秒\n";
}
return 0;
} |
|