15周项目三

来源:互联网 发布:淘宝网店在那找货源 编辑:程序博客网 时间:2024/05/16 07:23
/**Corpyright (c)2013,烟台大学计算机学院*All right reseved.*作者:张梦佳*完成日期:2014年6月2日*版本号:v1.0*输入描述:*问题描述:*程序输出:*问题分析:*算法设计:*/#include<stdlib.h>#include <iostream>#include<cstdio>    //支持freopen的头文件#include <fstream>using namespace std;class Dictionary{public:    friend istream& operator>>(istream& out,Dictionary &h)    {        out>>h.emean>>h.mean>>h.wordclass;        return out;    }    void chazhao(string a)    {        if(a==emean)            cout<<mean<<" "<<wordclass<<endl;    }    bool chazhao1(string a)    {        bool f=false;        if(a==emean)            f=true;        return f;    }private:    string emean;    string mean;    string wordclass;};int main( ){    int num1=0;    string h;    Dictionary t[9000];    ifstream infile("dictionary.txt",ios::in);    if(!infile)    {        cout<<"error!"<<endl;        exit(1);    }    while(infile>>t[num1])    {        num1++;    }    infile.close();    while(cin>>h)    {        bool s=false;        for(int i=0;i<num1;i++)        {            s=t[i].chazhao1(h);            t[i].chazhao(h);            if(s==true)                break;        }        if(s==false)            cout<<"查无此词!"<<endl;    }    return 0;}



0 0