#include <iostream>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	cout << s1 << s2 << endl;

	string word;
	while (cin >> word)
		cout << word << endl;

	string line;
	while (getline(cin, line))
		if(line.size()>80)
			cout << line << endl;

	string s1 = "hello", s2 = "world";
	string s3 = s1 + "," + s2;

	cout << s3 <<endl;

	//string s5 = "hello" + ", ";//错误 加法运算符要至少有一个是string对象

	string str("some string");
	for (auto c : str)
		cout << c << endl;

	string s1 ;
	cin >> s1;
	for (auto &c : s1)
		c = 'X';
	cout << s1 << endl;

	//去除字符串中的标点符号
	string s1("my lover, i miss u so much!!");
	string s2;
	for (auto c : s1)
		if (!ispunct(c))
			s2 += c;
	cout << s2 << endl;


		
	system("pause");

	return 0;
}
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐