题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
#include <stdio.h> #include <string.h> int main() { char buf[10000] = { 0 }; int i = 0; gets(buf); for (i = strlen(buf) - 1; i >= 0; i--) { if ((buf[i] > 'z' || buf[i] < 'a') && (buf[i] > 'Z' || buf[i] < 'A')) { if (buf[i+1] != '\0') { printf("%s ", &buf[i + 1]); } buf[i] = '\0'; } } printf("%s", buf); return 0; }