只要能实现这种效果就行。 - # include <stdio.h>
- # include <stdlib.h>
- # include <string.h>
-
- char* classify (char*);
-
- int main (){
- char *test = "bBAathToHOMmEe";
- char *clas = classify(test);
-
- puts(clas);
-
- }
-
- # define new(T, N) malloc ((N) *sizeof(T))
- char* classify(char *test){
- int len = strlen (test);
- char *ret = new(char, len + 1);
- ret[len] = 0;
- int i = 0, j = len - 1;
-
- for (char *a = test, *b = test + j; i <= j; a++, b--) {
- if (*a >= 'a') ret[i++] = *a;
- if (*b < 'a') ret[j--] = *b;
- }
- return ret;
- }
复制代码
|