A-A+
没写清楚的MS笔试题
char * removeSpace(char *p) { bool restart = true; char* r = p; char* s = p; while (*p != '\0') { if(restart){ while(isSpace(*p)) p++; restrart = false; } if(!isSpace(*p)&&!isNewline(*p)) *r++ = *p++; else if (isSpace(*p)) { while(isSpace(*p)) p++; if(isNewline(*p)) { *r++ = '\n'; restart = true; } else { *r++ = ' '; *r++ = *p++; } } else if(isNewline(*p)) { *r++ = *p++; restart = true; } } *r = '\0'; return s; } |