# include "stdio.h" # define N 100 main() { char s[N],a; int i,j,t; printf("请输入字符串:"); gets(s); for(i=0;i<N;i++) for(j=i+1;j<N;j++) if(s[j]==s[i]) { a=s[j]; for(t=j;t<N;t++) s[t]=s[t+1]; for(t=N;t>i+1;t--) s[t]=s[t-1]; s[i+1]=a; } printf("顺序为:%s\n",s); }