Andy's First Dictionary---set,stringstream
2024-09-28 17:41:32
https://cn.vjudge.net/contest/177260#problem/C
stringstream :https://blog.csdn.net/xw20084898/article/details/21939811
学习:http://www.cnblogs.com/yjlblog/p/6947747.html
注意set的*
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<set>
#include<cctype>
#include<sstream>
#define mem(a) memset(a,0,sizeof(a))
#define LL long long
using namespace std;
const long long N=1e9+;
set<string>ans;
int main()
{
//用set,元素只能出现一次,并且插入可以从小到大排序
string s,tmp;
while(cin>>s)
{
for(size_t i=;i<s.size();i++) //size_t一般用来表示一种计数
if(isalpha(s[i])) //小写字母返回2,大写字母返回1
s[i]=tolower(s[i]); //变小写
else s[i]=' ';
stringstream ss(s);
while(ss>>tmp) ans.insert(tmp); //向tmp中写入值,传值<<,
}
for(set<string>::iterator it=ans.begin();it!=ans.end();it++)
{
cout<<*it<<endl;
/*set不是数组 只能通过迭代器(iterator)把里面的元素倒出来
迭代器相当于是指针 扫描的是地址 因此输出的时候需要用*variation*/
}
return ;
}
//输出时在空行输入 ctrl+z+回车
最新文章
- C#基于Socket的简单聊天室实践
- CSS3选择器的研究,案例
- ffmpeg解码视频流
- [转]IntelliJ Idea 常用快捷键 列表(实战终极总结!!!!)
- Google Chrome开发者工具
- Angualar:指令大全
- 【算法】简单动态规划——三逆数的O(N^2)解法!
- c语言编程之双向循环链表
- bing 输入法,切换简体、繁体快捷键与myeclipse 格式化代码冲突。。
- android开发之SnackBar的使用
- silverlight 打印
- DBSCAN(Density-based spatial clustering of applications with noise)
- 开始DDD
- spring @Component
- OpenGL ES2.0光照
- 二级导航 js
- ps快捷键(有道云笔记翻出来以前的存货)
- HQL数据查询基础
- java 中的闭包
- [Swift实际操作]七、常见概念-(5)使用NSString对字符串进行各种操作