基本思想:
无;
关键点:
无;
#include<iostream>
#include<string>
#include<vector>
#include<set>
using namespace std;
const int maxn = 400;
vector<int> num[maxn];
bool vis[maxn];
int index;
int main() {
	string s;
	while (cin >> s) {
		for (int i = 0; i < maxn; i++)
			num[i].resize(0);
		fill(vis, vis + maxn, true);
		for (int i = 0; i < s.size(); i++) {
			index = s[i];
			num[index].push_back(i);
		}
		for (int i = 0; i < s.size(); i++) {
			index = s[i];
			if (num[index].size() >= 2) {
				if (vis[index]) {
					vis[index] = false;
					for (int j = 0; j < num[index].size(); j++) {
						if (j == 0)
							printf("%c:%d", s[i], num[index][j]);
						else
							printf(",%c:%d", s[i], num[index][j]);
					}
					cout << endl;
				}
			}
		}
	}
}
原文:https://www.cnblogs.com/songlinxuan/p/12459549.html