Andy's First Dictionary
Andy's First Dictionary
SCUACM2022集训前训练-数据结构 - Virtual Judge (vjudge.net)
stringstream
把单词从字符串里分离出来,可以先把字符串里的非字母字符变成 空格, 再放入 stringstream 中,再读 stringstream 这样单词就被分离出来了
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <sstream>
using namespace std;
typedef long long ll;
set<string> st;
int main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
string s;
while(cin >> s)
{
for (int i = 0; i < s.size(); i++)
{
if (isalpha(s[i]))
s[i] = tolower(s[i]);
else
s[i] = ' ';
}
stringstream ss(s);
while(ss >> s)
st.insert(s);
}
for (auto str : st)
cout << str << endl;
return 0;
}
分类:
acm / 字符串
标签:
字符串
, stringstream
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
· 零经验选手,Compose 一天开发一款小游戏!