从键盘输入若干个字符串,并按顺序输入输出

img


输入若干行字符串并按顺序输出
例子:输入
hello world
how are you
fine think you
输出
hello world
how are you
fine think you

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s[1000];
    int n=0;
    cin>>s[n];
    while(s[n].length() != 0)
    {
        n++;
        cin>>s[n];
    }
    for(int i=0;i<n;i++)
        cout<<s[i]<<endl;
    return 0;
}
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string line;
    while (cin >> line)
        cout << line << endl;
    return 0;
}