题目:把一个字符串分类,左边是数字,右边是字母。
输入:3j35j3de
输出:3353jjde
#include <stdio.h>
#include <string.h>
int main()
{
char str[100], temp;
int i, j, len;
while (scanf("%s", str) != EOF) {
i = 0; len = (int)strlen(str); j = len-1;
while (i < j) {
while (i < j && (str[i] >= '0' && str[i] <= '9')) {
i++;
}
while (i < j && ((str[j] <= 'z' && str[j] >= 'a') || (str[j] >= 'A' && str[j] <= 'Z'))) {
j--;
}
if (i <= len && j>= 0) {
temp = str[i];
str[i] = str[j];
str[j] = temp;
}
}
printf("%s\n", str);
}
return 0;
}