我把我写的发上来。我在想有没有在快点的算法。。。。。
void onSite(char pszArr[])
{
int left = 1;
int right = strlen(pszArr) - 1;
int cnt;
bool flag;
do
{
flag = false;
//小写字母往前
for (int i = right; i >= left; i--)
{
if ((pszArr[i] & 96) == 96 && (pszArr[i-1] & 96) != 96)
{
char tmp;
tmp = pszArr[i];
pszArr[i] = pszArr[i - 1];
pszArr[i - 1] = tmp;
cnt = i;
flag = true;
}
if (!flag)
{
cnt = left;
}
}
left = cnt + 1;
//大写字母往后
for (i = left; i <= right; i++)
{
if ((pszArr[i] & 96) != 64 && (pszArr[i-1] & 96) == 64)
{
char tmp;
tmp = pszArr[i];
pszArr[i] = pszArr[i - 1];
pszArr[i - 1] = tmp;
cnt = i;
}
}
right = cnt - 1;
} while (left < right);
}