请求大神帮忙解答一下 谢谢

编写函数LoopMove ,对一个字符串重新排列,字母排在前面,数字排在后面,最后是其它字符,并且保证字符的先后顺序不变。例如输入字符串“1tv*a34”,则输出“tva134*”。

#include “stdio.h”
void LoopMove (char *s, int nLen)
//s -- 字符串
//nLen -- 字符串长度
{
//这里开始写程序
}
void main()
{
char c[] = “1tv*a34”;
printf(“排列前%s\n”, c);
LoopMove(c, 7);
printf(“排列后%s\n”, c);
return;
}

http://codepad.org/wK0bRqnT

Output:

排列前1tv*a34
排列后atv134*

 #include "stdio.h"

int comp(int ch1, int ch2)
{
    if (ch1 >= '0' && ch1 <= '9') ch1 = -1;
    if (ch1 >= 'a' && ch1 <= 'z') ch1 = -2;
    if (ch1>0) ch1 = 0;

    if (ch2 >= '0' && ch2 <= '9') ch2 = -1;
    if (ch2 >= 'a' && ch2 <= 'z') ch2 = -2;
    if (ch2>0) ch2 = 0;

    return ch1 - ch2;
}

void LoopMove(char *s, int nLen)
{
for (int i = 0; i < nLen - 1; i++)
{
    for (int j = 0; j < nLen - i - 1; j++)
    {
        if (comp(*(s + j), *(s + j + 1)) > 0)
        {
            char t = *(s + j);
            *(s + j) = *(s + j + 1);
            *(s + j + 1) = t;
        }
    }
}
}
int main()
 {
 char c1[] = "1tv*a34";
char * c = new char[100];
strcpy(c, c1);
printf("排列前%s\n", c);
 LoopMove(c, 7);
 printf("排列后%s\n", c);
 return 0;

http://codepad.org/r1Z6s468