C++这个程序怎么修改

img

for(j=0;j<len-1;j++)    //冒泡排序
{
    for(i=0;i<len-1-j;i++)
    {
        if(str[i]>str[i+1])
        {
            temp=str[i+1];
            str[i+1]=str[i];
            str[i]=temp;
        }
    }
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <math.h>

int main()
{
    char* str = (char*)malloc(sizeof(char)*1000000);
    strset(str,0);
    scanf("%s",str);
    char* shuzi = (char*)malloc(sizeof(char) * 1000000);
    strset(shuzi, 0);
    char* zimu = (char*)malloc(sizeof(char) * 1000000);
    strset(zimu, 0);
    char* ZiMu = (char*)malloc(sizeof(char) * 1000000);
    strset(ZiMu, 0);
    int x = 0;
    int nums = 0;
    int numz = 0;
    int numZ = 0;
    char buf;
    while (str[x]!='\0')
    {
        if (str[x]>='0'&&str[x]<='9')
        {
            shuzi[nums] = str[x];
            nums++;
            str[x] = '0';
        }
        if (str[x] >= 'a' && str[x] <= 'z')
        {
            zimu[numz] = str[x];
            numz++;
            str[x] = 'a';
        }
        if (str[x] >= 'A' && str[x] <= 'Z')
        {
            ZiMu[numZ] = str[x];
            numZ++;
            str[x] = 'A';
        }
        x++;
    }
    for (int i = 0; i < nums - 1; i++)
    {
        //数字数组shuzi排序
        for (int j = 0; j < nums - 1 - i; j++)  //每轮比较n-1-i次,
        {
            if (shuzi[j] > shuzi[j + 1])
            {
                buf = shuzi[j];
                shuzi[j] = shuzi[j + 1];
                shuzi[j + 1] = buf;
            }
        }
    }
    for (int i = 0; i < numz - 1; i++)
    {
        //字母数字zimu排序
        for (int j = 0; j < numz - 1 - i; j++)  //每轮比较n-1-i次,
        {
            if (zimu[j] > zimu[j + 1])
            {
                buf = zimu[j];
                zimu[j] = zimu[j + 1];
                zimu[j + 1] = buf;
            }
        }
    }
    for (int i = 0; i < numZ - 1; i++)
    {
        //字母数字ZiMu排序
        for (int j = 0; j < numZ - 1 - i; j++)  //每轮比较n-1-i次,
        {
            if (ZiMu[j] > ZiMu[j + 1])
            {
                buf = ZiMu[j];
                ZiMu[j] =ZiMu[j + 1];
                ZiMu[j + 1] = buf;
            }
        }
    }
    x = 0;
    nums = 0;
    numz = 0;
    numZ = 0;
    while (str[x] != '\0')
    {
        if (str[x] == '0')
        {
            str[x] = shuzi[nums];
            nums++;
        }
        if (str[x] == 'a')
        {
            str[x] = zimu[numz];
            numz++;
        }
        if (str[x] == 'A')
        {
            str[x] = ZiMu[numZ];
            numZ++;
        }
        x++;
    }
    printf("%s",str);
    return 0;
}