Topic 1094: Input and Output Processing of Strings

Insert picture description here

#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;
}

Guess you like

Origin blog.csdn.net/qq_43811879/article/details/109104681