primer 1112

/*************************************************************************
	> File Name: test6.cpp
	> Author:keson 
	> Mail:[email protected] 
	> Created Time: 2015年01月23日 星期五 14时19分33秒
 ************************************************************************/

#include<iostream>
#include<vector>
#include<utility>
#include<sstream>
using namespace std;

pair<string,int> process(string &line)
{
    string s;
    int val;
    istringstream record(line);
    record>>s>>val;
    return {s,val};
}
int main()
{
    vector<pair<string,int>> words;
    cout<<"Enter the strings and numbers:"<<endl;
    string line;
    while(getline(cin,line))
        words.push_back(process(line));
    cout<<endl;
    cout<<words.size()<<endl;
    for(auto word:words)
      cout<<word.first<<" "<<word.second<<endl;
}

你可能感兴趣的:(primer 1112)