【例题5-4 UVA - 156】Ananagrams
2024-08-23 11:28:29
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
每个字符串如果每个字符按照升序排一下。假设他们能够互相变化。
则肯定是一样的。
根据这个东西,用一个map来判重就好。
【错的次数】
在这里输入错的次数
【反思】
在这里输入反思
【代码】
#include <bits/stdc++.h>
using namespace std;
string s;
vector<string> words, ans;
map <string, int> mymap;
string pack(string t)
{
int len = t.size();
for (int i = 0; i < len; i++)
t[i] = tolower(t[i]);
sort(t.begin(), t.end());
return t;
}
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
ios::sync_with_stdio(0), cin.tie(0);
while (cin >> s)
{
if (s[0] == '#') break;
words.push_back(s);
mymap[pack(s)]++;
}
int len = words.size();
for (int i = 0; i < len; i++)
if (mymap[pack(words[i])] == 1)
ans.push_back(words[i]);
sort(ans.begin(), ans.end());
for (string x : ans)
cout << x << endl;
return 0;
}
最新文章
- C++中的时间函数
- YII的Modules模块化
- css3动画效果
- MySQL数据恢复和复制对InnoDB锁机制的影响
- 转:Microsoft Enterprise Library 5.0 系列教程(一) Caching Application Block (高级)
- &ldquo;锁定&rdquo;语句 lock(C# 参考)
- Js数组去重复取唯一值
- 实际中理解div布局和浮动
- [转] GDB attach
- 轻松完成WAP手机网站搭建
- PHP二维数组排序函数
- Android studio多个项目之间怎么实现快速切换?
- 201521145048《Java程序设计》第6周学习总结
- Mysql无法启动 InnoDB: Attempted to open a previously opened tablespace
- webpack构建本地服务器
- java并发包——阻塞队列BlockingQueue及源码分析
- ASCII与HEX对照转换表
- 洛谷[LnOI2019]长脖子鹿省选模拟赛 简要题解
- xadmin的使用
- Windows 7 编译64位boost库