题解 | 找位置

#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")

全部评论

相关推荐

酷酷我灵儿帅:这去不去和线不线下面说实话没啥关系
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 14:23
steelhead:你回的有问题,让人感觉你就是来学习的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务