展开全部
总得思想还是冒泡排序,改良一下就可以了e69da5e887aa62616964757a686964616f31333335343961。#include
#include
#include
int main(void)
{
char a[300];
char temp;
int len;
int loop, loop1;
int flag;
gets(a);
len = (int)strlen(a);
/* 冒泡排序算法 */
for(loop = 0; loop
{
if(a[loop] >= 'a' && a[loop] <= 'z') //小写字母
{
flag = 1;
}
else if(a[loop] >= 'A' && a[loop] <= 'Z') //大写字母
{
flag = 2;
}
else if(a[loop] >= '0' && a[loop] <= '9') //数字
{
flag = 3;
}
else //啥也不是
{
continue;
}
for(loop1 = loop + 1; loop1
{
if(flag == 1)
{
if(a[loop1] >= 'a' && a[loop1] <= 'z')
{
if(a[loop] > a[loop1])
{
temp = a[loop];
a[loop] = a[loop1];
a[loop1] = temp;
}
}
else
{
continue;
}
}
else if(flag == 2)
{
if(a[loop1] >= 'A' && a[loop1] <= 'Z')
{
if(a[loop] > a[loop1])
{
temp = a[loop];
a[loop] = a[loop1];
a[loop1] = temp;
}
}
else
{
continue;
}
}
else
{
if(a[loop1] >= '0' && a[loop1] <= '9')
{
if(a[loop] > a[loop1])
{
temp = a[loop];
a[loop] = a[loop1];
a[loop1] = temp;
}
}
else
{
continue;
}
}
}
}
printf("%s\n", a);
return 0;
}