题解 | 找位置
#include <iostream> #include<algorithm> #include<map> #include<vector> using namespace std; int main() { string s; cin >> s; map<char, int> m; for (int i = 0; i < s.size() - 1; i++) { int flag = 0; if (m.find(s[i]) != m.end()) { continue; } m[s[i]] = 1; for (int j = i + 1; j < s.size(); j++) { if (s[i] == s[j]) { if (flag == 0) { cout << s[i] << ":" << i; flag = 1; } cout << "," << s[i] << ":" << j; } } if (flag == 1) cout << endl; } } // 64 位输出请用 printf("%lld")