题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584
#include <string.h>
int main()
{
int i,j,k=0;
char str[1002]={0},copy[1002]={0};
fgets(str, sizeof(str), stdin);
strcpy(copy,str);
for(i=0;i<1000;i++)
{
if((65<=copy[i]&©[i]<=90)||(97<=copy[i]&©[i]<=122))
copy[i]='a';
if(copy[i]=='\0')
break;
}
for(j=0;j<26;j++)
{
for(i=0;i<1000;i++)
{
if(str[i]==(65+j)||str[i]==(97+j))
{
if(copy[k]=='a')
{
copy[k]=str[i];
k++;
}
else
{
k++;
i--;
}
}
}
}
printf("%s",copy);
}