有一个由大小写组成的字符串,现在需要对它进行修改,将其中的所有小写字母排在大写字母的前面(大写或小写字母之间不要求保持原来次序)。
while(head < tail)
{
while(*(str + head) < 'A' || *(str + head) > 'Z')
head++;
while(*(str + tail) < 'a' || *(str + tail) > 'z')
tail--;
swap(*(str + head), *(str + tail));
}
}
int main(int argc, char *argv[])
{
char str[MAX] = {'/0'};
cin.getline(str, 100);
handleStr(str);
cout << "swap result is: " << endl;
cout << str << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
还有点问题 。。。
while(head < end)
{
if(isUpperCase(str[head]))
{
while(isUpperCase(str[end]))
end--;
swap(str[head++], str[end--]);
}
else
head++;
}
}
int main(int argc, char *argv[])
{
char a[] = {"abcdefgHIGKLMNopqistUV"};
hanStr(a);
cout << a << endl;
system("PAUSE");
return EXIT_SUCCESS;
}