////////////////////////////////////////////////////////////////////////////////////////////////////
//濒临吐血
////////////////////////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <cstdio>
#include <string>
#include <queue> //队列库
using namespace std;
const int MAXSIZE = 100;
struct ALPHA
{
char str1; //不重复字母有哪些
int number; //重复次数
queue<int> pos; //重复字母下标记录队列
};
ALPHA alpha[MAXSIZE];
int main()
{
string str; //sting str;不是数组;一个串,是一个文件;放里边
while(getline(cin,str))
{
alpha[0].str1=str[0]; //把首个字母放在字母串第一个位置
alpha[0].pos.push(0); //把第一个字母的下标也就是0推进下标队列
alpha[0].number=1;//第一个字母,现在只出现了1个,字母目前为止出现的个数
int k=1;//无重复字母串目前有一个字母
for(int i=1; i<str.size(); ++i) //把str串,挨个轮一遍,分类,收纳
{
int m=k;//在循环里,防止k重复刷
//把str里的每一个字母与alpaha挨个比较,相同就记录下标,不同就往alpha里添加新字母
for(int j=0;j<m;++j){ //j<m,m是个数!!!!!!!!!!!!!!!!!!!!!!!!
if(str[i]==alpha[j].str1){ //如果相同就在对应字母下添加位置
alpha[j].pos.push(i);
alpha[j].number++; //每一个添加,个数就增加一个
break;//要是重复就下一个字母
}
if(j==m-1){//要是到最后一个,还没跳出,就说明不是重复的,就得新增!!!!!!!!!!!!!!!!!1
alpha[k].str1=str[i];//反正就是在k这个下标新增,第k+1个,下标是k,字母存进去
alpha[k].pos.push(i);//下标存进去
alpha[k].number=1;//新增,重复一次
k++;//这回第k+1个不重复字母了!!!!!!!!!!!!!!!!!!!!!这很恶心!!!!!!!
}
}
}
for(int i=0;i<k;++i){ //i<k,k是个数
if(alpha[i].number>1){
for(int p=0; p<alpha[i].number; ++p)
{
printf("%c:%d",alpha[i].str1,alpha[i].pos.front());//front是访问队头,不删除!!!!!
alpha[i].pos.pop();//这个才是删除队头呢!!!!!!!!!!!!!
if(p!=alpha[i].number-1)
{
printf(",");
}else{
printf("\n");
}
}
}
}
}
}
// #include <iostream>
// #include <cstdio>
// #include <string>
// #include <queue>
// using namespace std;
// const int MAXSIZE = 100;
// struct ALPHA
// {
// char str1;
// int number;
// queue<int> pos;
// };
// ALPHA alpha[MAXSIZE];
// int main()
// {
// string str; //sting str;不是数组;一个串,是一个文件;放里边
// while(getline(cin,str))
// {
// alpha[0].str1=str[0];
// alpha[0].pos.push(0);
// alpha[0].number=1;//a有几个重复的
// int k=1;//个数
// int m;
// // printf("%d\n",str.size());
// for(int i=1; i<str.size(); ++i)
// {
// // printf("%d\n",i);
// m=k;
// // if(i==12) printf("%d\n",k);
// // printf("%d\n",i);
// for(int j=0;j<m;++j){
// // if(i==12) {
// // printf("%c\n",str[i]);
// // }
// // if(j==2) {
// // printf("%c\n",alpha[j].str1);
// // }
// if(str[i]==alpha[j].str1){
// // printf("%d\n",i);
// alpha[j].pos.push(i);
// alpha[j].number++;
// // if(i==11) printf("%d\n",alpha[7].number);
// // printf("[%d+] ",i);
// break;
// }
// if(j==m-1){
// // printf("(%d-) ",i);
// // number[i]++;
// alpha[k].str1=str[i];
// alpha[k].pos.push(i);
// alpha[k].number=1;
// k++;
// }
// }
// }
// // printf("%d\n",k);
// // for(int i=2;i<k;++i){
// // printf("%d:%c\n",i,alpha[i].str1);
// // }
// for(int i=0;i<k;++i){
// if(alpha[i].number>1){
// // printf("%d\n",alpha[7].number);
// for(int p=0; p<alpha[i].number; ++p)
// {
// printf("%c:%d",alpha[i].str1,alpha[i].pos.front());//front是访问队头,不删除!!!!!
// // printf("(%d)",alpha[i].pos.front());
// alpha[i].pos.pop();//这个才是删除队头呢!!!!!!!!!!!!!
// // printf("(%d)",alpha[i].pos.front());
// if(p!=alpha[i].number-1)
// {
// printf(",");
// }else{
// printf("\n");
// }
// }
// }
// }
// }
// }
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //自虐玩法 256个ASCII挨个遍历,用上了队列!!!!自杀式玩法,答案缺个排序
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// #include <iostream>
// #include <cstdio>
// // #include <algorithm>
// #include <string>
// // #include <cstring>
// #include <queue>
// using namespace std;
// const int MAXSIZE = 256;
// // const int length = 100;
// // int number[MAXSIZE];
// // const int MAXSIZE = 100;
// // struct ALPHA{
// // char str1;
// // int pos[MAXSIZE];
// // int number;
// // };
// struct ALPHA
// {
// char str1;
// // int pos[length];
// int number;
// queue<int> pos;
// };
// ALPHA alpha[MAXSIZE];
// int main()
// {
// string str; //sting str;不是数组;一个串,是一个文件;放里边
// while(getline(cin,str))
// {
// // int j[length];
// // memset(j,0,length);
// for(int i=0; i<str.size(); ++i)
// {
// // number[i]++;
// // number[str[i]-' ']++;
// alpha[str[i]].str1=str[i];
// alpha[str[i]].number++;
// // alpha[str[i]].pos[++j[str[i]]]=i;
// alpha[str[i]].pos.push(i);
// }
// // for(int i=0; i<MAXSIZE; ++i)
// // {
// // printf("%d ",alpha[i].number);
// // }
// // memset(j,0,MAXSIZE);
// for(int i=0; i<MAXSIZE; ++i)
// {
// if(alpha[i].number>1)
// {
// for(int p=0; p<alpha[i].number; ++p)
// {
// printf("%c:%d",alpha[i].str1,alpha[i].pos.front());//front是访问队头,不删除!!!!!
// alpha[i].pos.pop();//这个才是删除队头呢!!!!!!!!!!!!!
// // printf("%c:",alpha[i].str1);
// if(p!=alpha[i].number-1)
// {
// printf(",");
// }else{
// printf("\n");
// }
// }
// }
// }
// }
// }
// // while(getline(cin,str)){
// // for(int i=0;i<str.size();++i){
// // printf("\n");
// // }
// // int i;
// // if(alpha[i].number>1){
// // for(int j=0;j<alpha[i].number;++j){
// // printf("%c:%d",alpha[i].str1,alpha[i].pos);
// // if(j==alpha[i].number-1){
// // printf(",");
// // }
// // }
// // }
// // }
// // }
// // printf("%d ",number[i]);