首页 > 其他 > 详细

第二次作业

时间:2018-10-01 00:54:21      阅读:398      评论:0      收藏:0      [点我收藏+]

作业地址:https://edu.cnblogs.com/campus/nenu/2016CS/homework/2139

git仓库: https://git.coding.net/tangjh563/wfAnalysis.git

时间:

技术分享图片

主要算法:

 

void Cwords(){
    map<string,int> wcount;
    bool flag = gnumber();
    bool tmp = false;
    string w;
    string s;
    for (int i = 0;i < zfc.length();i++){
        while(zfc[i] >= 0 && zfc[i] <= 9 || zfc[i] >= a && zfc[i] <= z){
            tmp = true;
            s += zfc[i];
            i++;
        }
        if(tmp){
            w = s;
            if(w[0] > 9 || w[0] < 0){
                //vector<int>::iterator result = find( L.begin( ), L.end( ), 3 );
                ++wcount[w];
            }
            s = "";
            w = "";
            tmp = false;
        }
    }
    if(!flag){
        cout << "total " << wcount.size() << " words" << endl;
        for(map<string,int>::iterator it = wcount.begin() ; it != wcount.end() ; it++)
            cout << left << setw(20) << it->first << it->second << endl;
    }
    else{
        cout << "Total words is " << wcount.size() <<endl;
        cout <<"-----------------------------------------" << endl;
        vector<pir> word_count(wcount.begin() , wcount.end());
        for (int i = 0;i < num1;i++)
            cout << left << setw(20) << word_count[i].first << word_count[i].second << endl;
    }

 

第二次作业

原文:https://www.cnblogs.com/tangjh563/p/9733832.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!