#include <fstream>
#include <string>
#include <iostream>
using namespace std;
string english[8000],chinese[8000];
int main()
{
string find_english;
string find_chinese;
int i, j;
ifstream infile("dictionary.txt", ios::in);
if(!infile)
{
cerr << "open error!" << endl;
exit(1);
} //文件是否打开;
for(i = 0; i < 8000; i++)
{
infile >> english[i] >> chinese[i];
}
infile.close();
do
{
bool flag = false;
cout << "请输入您要查询的英语单词(直到输入0000结束):" << " ";
cin >> find_english;
for(i = 0; i < 8000; i++)
{
while(find_english == "0000")
{
flag = true;
break;
}
if(find_english == english[i])
{
cout << chinese[i] << endl;
flag = true;
break;
}
}
if(flag == false) cout << "can't find this worrd" << endl;
}while(find_english!="0000");
return 0;
}
运行结果: