您的位置:首页 > 移动开发 > IOS开发

第十六周实验报告 任务三(最简)

2012-06-05 01:43 381 查看
源程序·:

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;

class Word
{
public:
Word()
{
word = 'a';
translate = 'a';
cixing = 'a';
}

Word(string w, string t, string ci):word(w), translate(t), cixing(ci){}

string get_word()
{
return word;
}

friend void cin_word(Word w[])
{
ifstream infile("dictionary.txt",ios::in);

if(!infile)
{
cerr << "open error!!!";
exit(1);
}

for(int i = 0; i < 8000; ++ i)
{
infile >> w[i].word >> w[i].translate >> w[i].cixing ;
}

infile.close();
}

void display()
{
cout << word << '\t' << translate << '\t' << cixing << endl;
}

private:
string word;
string translate;
string cixing;
};

int main()
{
Word w[8000];
string chinese;
int i;
cin_word(w);

cout << "请输入要查询单词:";

cin >> chinese;

for (i = 0; i < 8000; ++ i)
{
if(chinese == w[i].get_word())
{
w[i].display();
break;
}
}

system("PAUSE");

return 0;
}


截图:



一个简单的电子词典···本来想今晚完成十六周任务···可是活动搞到好晚···今天成果好小···只好明天努力啦!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  任务 string system 活动 ios