标签:har \n ++ i++ char std 字符 [] pre
#include "string.h" #include "stdio.h" char * nixu(char *c) { int i=0; int n = strlen(c); char *p1 = c + n -1; char *p2 = c; char *p3 = c; while(p1>p2) { char a; a = *p1; *p1 = *p2; *p2 = a; p1--; p2++; } return p3; } char *word(char *c) { char *p = c; int n = strlen(c); int i = 0,j=0; for(i;i<n;i++) { if(*p == ‘ ‘) { *p = ‘\0‘; nixu(p-j); *p = ‘ ‘; j=0; } else j++; p++; } p-=n; return p; } int main() { char a[] = "I love china"; printf("%s\n",word(nixu(a))); return 0; }
标签:har \n ++ i++ char std 字符 [] pre
原文地址:https://www.cnblogs.com/dlutccj/p/10165780.html