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;
}
复制代码

 

posted @   花与不易  阅读(189)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示