题解 | #找位置#
找位置
https://www.nowcoder.com/practice/e3b2cc44aa9b4851bdca89dd79c53150
#include<iostream>
#include<cstring>
using namespace std;
const int N = 200;
int a[N];
int e[N][N];
int main(){
string str;
cin >> str;
memset(e, -1, sizeof e);
for(int i = 0; i < str.size(); i ++){
int x = str[i];
e[x][a[x]] = i;
a[x] ++;
}
for(int i = 0; i < str.size(); i ++){
if(a[str[i]] > 1 && i == e[str[i]][0]){
for(int j = 0; j < a[str[i]]; j ++){
if(e[str[i]][j] != -1) printf("%c:%d", str[i], e[str[i]][j]);
if(j == a[str[i]] - 1) printf("\n");
else printf(",");
}
}
}
return 0;
}

