ACM模式下连续输入数字和带空格的字符串
#include <iostream> #include <string> #include <vector> using namespace std; int mainssss() { //一个词语在标题出现一次相当于三次,在正文出现一次相当于一次 //top3高频的词。 int topN, paperCount; //topN = 3, paperCount = 2; cin >> topN >> paperCount; vector<string> title; vector<string> paper; cin.get();//数字和字符串的间隔必须输入这个 for (int i = 0; i < paperCount; i++) { string aa;//必须用string定义,不能直接输入到title[i] getline(cin, aa); title.push_back(aa); string bb; getline(cin, bb); paper.push_back(bb); } for (auto t : title) { cout << "title:" << t << endl; } for (auto p : paper) { cout << "paper:" << p << endl; } return 0; }