哪些网站可以做养殖的广告,佛山外贸建站,网站上线倒计时html5模板,只做网站哪个云服务器好字母异位词分组
题目描述
给定一个字符串数组#xff0c;将字母异位词组合在一起。字母异位词指字母相同#xff0c;但排列不同的字符串。
输入格式
第一行正整数n#xff0c;表示有n个字符串(1n1000) 第二行n个字符串#xff0c;空格隔开
输出格式
多组字母…字母异位词分组
题目描述
给定一个字符串数组将字母异位词组合在一起。字母异位词指字母相同但排列不同的字符串。
输入格式
第一行正整数n表示有n个字符串(1n1000) 第二行n个字符串空格隔开
输出格式
多组字母异位词每组占一行每个字符串空格隔开每组字符次序与原字符串前后次序不变。
样例 #1
样例输入 #1
6
eat tea tan ate nat bat样例输出 #1
eat tea ate
tan nat
bat#includebits/stdc.h
using namespace std;
string s, x, c[1000];
mapstring, string b;
int n, cnt 0;
int main() {cin n;for (int i 1; i n; i) {cin s;x s;sort(x.begin(), x.end());if (b.find(x) b.end()) {//新词b[x] s;c[cnt] x;} else {//已有的就合在一起b[x] b[x] s;}}for (int i 1; i cnt; i) {cout b[c[i]] endl;}return 0;
}