第十六周实验报告 任务三(最简)
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;
}
截图:
一个简单的电子词典···本来想今晚完成十六周任务···可是活动搞到好晚···今天成果好小···只好明天努力啦!!!
#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;
}
截图:
一个简单的电子词典···本来想今晚完成十六周任务···可是活动搞到好晚···今天成果好小···只好明天努力啦!!!
相关文章推荐
- C++程序设计实验报告(七十九)---第十六周任务一
- C++程序设计实验报告(八十三) --- 第十六周任务四
- C++程序设计实验报告(八十)---第十六周任务二
- C++程序设计实验报告(八十一)---第十六周任务三
- C++程序设计实验报告(八十二)---第十六周任务#3-2(学会二分查找)
- 第十六周实验报告(任务一)【涨工资】
- 第十六周实验报告任务3--电子词典
- 第十六周实验报告 任务三(改)
- 第十六周实验报告(四)---指针做 十四周任务2
- 第十六周实验报告任务1
- 第十六周实验报告任务2
- 《第十六周实验报告任务2——学生成绩排序》
- 第十六周实验报告(任务一)
- 第十六周实验报告(任务二)
- 《第十六周实验报告任务1——涨工资并排序 》
- 《第十六周实验报告任务3——电子词典》
- 第八周实验报告(任务一)【复数与复数的加减乘除】
- 第八周实验报告任务3
- 第九周实验报告(任务一)【Complex类中《和》运算符的重载】
- 第九周实验报告(任务5)