/*
*编写一段程序,从标准输入中读取多个字串并将他么连接起来,输出成大的字符串。
*改写上述程序,用空格把输入的多个字符串分割开来。*/
#include"stdafx.h"
#include"iostream"
#include"string"
using namespace std;
int main()
{
char cont = 'y';
string s, result;
cout << "请输入一个字符串:" << endl;
while (cin>>s)
{
//不加空格
//result += s;
//加空格
if (!result.size())//第一个拼接的字符串之前不加空格
result += s;
else
result = result + " " + s;
cout << "是或继续(y or n)?" << endl;
cin >> cont;
if (cont == 'y' || cont == 'Y')
cout << "请输入下一个字符串:" << endl;
else
break;
}
cout << "拼接后的字符串是:" << result << endl;
return 0;
}