第17周项目7-电子词典结构体版
来源:互联网 发布:python 替换字符串 编辑:程序博客网 时间:2024/06/07 17:23
/* *Copyright (c) 2014, 烟台大学计算机学院 *All rights reserved. *文件名称:week17-project7.cpp *作者:高赞 *完成日期:2014年 12 月 22 日 *版本号:v1.0 * */#include <fstream>#include <iostream>#include <iomanip>#include <cstdlib>#include <cstring>using namespace std;int main( ){ struct Word { string english; string wordclass; string chinese; } w[8000]; int i=0,sum=0; string a,b,c,word; ifstream infile("dictionary.txt",ios::in); if(!infile) { cerr<<"未找到该文件!"<<endl; exit(1); } while (infile >> a >> b >>c) { w[i].english=a; w[i].chinese=b; w[i].wordclass=c; ++i; ++sum; } infile.close(); do { int middle, low=0,high=sum; cout << "输入要查询的单词:" << endl; cin >> word; getchar(); middle=(low+high)/2; while(word!=w[middle].english) { if(word>w[middle].english) { low=middle+1; middle=(low+high)/2; } else { high=middle-1; middle=(low+high)/2; } if (low>high) { cout << "对不起,查无此词。" << endl; break; } } if(low<=high) cout << w[middle].wordclass <<'\t' << w[middle].chinese << endl; cout << endl << "回车键继续或其他任意键退出..." << endl << endl; } while (getchar()=='\n'); return 0;}
0 0
- 第17周项目7-电子词典结构体版
- 第17周项目7-电子词典结构体版
- 第17周项目7 电子词典结构体版
- 第17周项目7-电子词典结构体版
- 第17周项目7-电子词典结构体版
- 第17周项目7--电子词典结构体版
- 第17周项目电子词典结构体版
- 第17周 项目7 结构体电子词典
- 2014秋C++第17周 项目7参考 电子词典结构体版
- 第17周上机实践项目7——电子词典结构体版
- 第十七周项目电子词典结构体版
- 第十七周项目7-电子词典结构体版
- 第十七周 项目7 电子词典结构体版
- 第十七周 【项目7-电子词典结构体版】
- 第十七周项目 7 电子词典结构体版
- 第十七周项目7-电子词典结构体版
- 第十七周项目7 电子词典结构体版
- 第十七周 项目七:电子词典结构体版
- netty当中的release方法
- 一个有关ParametersInterceptor 的错误
- 000003 我的2014
- CString 转换成 char *
- ListView适配器Adapter介绍与优化
- 第17周项目7-电子词典结构体版
- Qt QLineEdit中屏蔽粘贴功能
- Device Tree(二):基本概念
- 谈Ajax的Get和Post的区别
- Oracle 数据库实例、监听器、EM
- nginx内存池基本原理及问题
- Device Tree(三):代码分析
- 第十七周项目二引用作形参
- vs制作库