トピック1094:文字列の入力および出力処理

ここに画像の説明を挿入

#include <bits/stdc++.h>
using namespace std;

int main()
{
    
    
    int n;cin>>n;
    getchar();
    string s; int cnt = 0;
    while(getline(cin,s)){
    
    
        cnt++;
        cout<<s<<endl;
        cout<<endl;
        if(cnt==n) break;
    }
    string s2;
    while(cin>>s2){
    
    
        cout<<s2<<endl;
        cout<<endl;
    }
    return 0;
}

おすすめ

転載: blog.csdn.net/qq_43811879/article/details/109104681