f0617.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //=================================
- // f0617.cpp
- // 清点单词数
- //=================================
- #include<iostream>
- #include<fstream>
- #include<sstream>
- #include<vector>
- #include<map>
- using namespace std;
- typedef multimap<int,int> Mmap;
- //---------------------------------
- int main(){
- ifstream in("abc.txt");
- vector<string> abc;
- // abc.reserve(1100);
- Mmap nums;
- int n=0;
- for(string s; getline(in,s); ){
- istringstream sin(s);
- int num=0;
- for(string t; sin>>t; num++);
- if(num){
- nums.insert(Mmap::value_type(num, n++));
- abc.push_back(s);
- }
- }
- for(Mmap::iterator it=nums.begin(); it!=nums.end(); ++it)
- cout<<abc[it->second]<<endl;
- }//=================================