可以尝试如下方案,亲测可行。

int main()
{
    string s1,s2;
    while(getline(cin,s1)&&getline(cin,s2))
    {
        cout<<s1<<endl;
        cout<<s2<<endl;
    }
    return 0;
}

以上是string类型的解决方案,下面是定义char数组如何处理的方法。

int main()
{
    char s1[100],s2[100];
    while(gets(s1)&&gets(s2))
    {
        cout<<s1<<endl;
        cout<<s2<<endl;
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章:

  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2021-06-09
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
相关资源
相似解决方案