stringstream流输出给string类时,自动忽略字符前面的空格

//#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <queue>
#include <vector>
#include <iterator>
#include <map>
#include <bitset>
#include <stack>
#include <deque>
#include <cmath>
#include <iomanip>
#include <forward_list>
#include <set>
#include <cmath>
#include <cctype>
#include <sstream>
#include <climits>
#include <list>
#include <typeinfo>
//INT_MAX 32 bit int
//LLONG_MAX 64 bit int
//LONG_MAX 64 bit int

using namespace std;

//#pragma comment(linker, "/STACK:3073741824")
#define memmin(a) memset(a,0,sizeof(a))
#define memmax(a) memset(a,0x3f,sizeof(a));
#define spr(n) fixed << setprecision(n)
#define endll '\n'
#define ifor(i, l, r) for (long long (i) = (l); (i) <= (r); ++(i))
#define rfor(i, r, l) for (long long (i) = (r); (i) >= (l); --(i))
#define fori(i,l,r) for(auto i=p;i!=p1;++i)
#define rfori(i,rl,rr) for(auto i=rl;i!=rr;++i)
#define coute cout<<'\n'
typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;

template <class T, class Container = vector<T>,
          class Compare = less<typename Container::value_type> >
using priqueue = priority_queue<T,Container,Compare>;

#define start1
#ifndef start1
const int IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1.0e-9;
const long long MOD = 1e9 + 7;
const int MAX1 = 1e5 + 100;
const int MAX2 = 1e7 + 100;

#endif

#define start2
#ifndef start2

//__int128读取
void  read(ll& w) {
	w=0;
	ll f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch <= '9' && ch >= '0') {
		w = w * 10 + ch - '0';
		ch = getchar();
	}
}

void print128(ll x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9)print128(x / 10);
	putchar(x % 10 + '0');
}

#endif

#define start3
#ifndef start3
template<typename container>
void _print(container &a2) {
	for (auto i = a2.begin(); i != a2.end(); i++) {
		if (i == a2.begin()) cout << *i;
		else
			cout << " " << *i;
	}
}

template<typename T1>
auto _print(T1 a1, ll l, ll r) ->void {
	for (ll i = l; i <= r; ++i) {
		if (i == l) cout << a1[i];
		else cout << " " << a1[i];
	}
}
#endif
set<string> das;
int main(int argv,char** argc) {
	//	ios::sync_with_stdio(false);
	//	cin.tie(0);
	//	cout.tie(0);
	string temp;
	string a;
	while(cin>>a) {
		ifor(i,0,a.size()-1) {
			if(isalpha(a[i])) {
				a[i]=tolower(a[i]);
			}
			else
			{
				a[i]=' ';
			}
		}
		stringstream ss(a);
		string b;
		while(ss>>b)
		{
			das.insert(b);
		}
	}
	for(auto ss:das) {
		cout<<ss<<endl;
	}
	return 0;
}

全部评论

相关推荐

2024-12-29 19:48
河北科技大学 Java
没事就爱看简历:问题不在于简历:1、大学主修课程学那么多应用语言,作为计算机专业是很难理解的。 2、技能部分,每一个技能点的后半句话,说明对熟练,熟悉的标准有明显误会。 3、项目应该是校企合作的练习吧,这个项目你负责什么,取得了哪些成果都没有提及,只是列举了你认为有技术含量的点,而这些都有成熟的实现。
点赞 评论 收藏
分享
01-18 09:26
已编辑
门头沟学院 Java
王桑的大offer:建议中间件那块写熟悉即可,写掌握 面试包被拷打到昏厥
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务