题解 | #找位置#
找位置
https://www.nowcoder.com/practice/e3b2cc44aa9b4851bdca89dd79c53150
#include <stdio.h> #include <stdlib.h> int main() { char str[100]; while (scanf("%s", str) != EOF) { for(int i=0;i<strlen(str);i++){ int flag=0; for(int j=i+1;j<strlen(str);j++){ if(str[i]==str[j] && str[i]!='*'){ flag++; if(flag==1){ printf("%c:%d",str[i],i); printf(",%c:%d",str[i],j); } else{ printf(",%c:%d",str[i],j); } str[j]='*'; } } if(flag){ printf("\n"); } } } return 0; }