题解 | #句子逆序#
句子逆序
http://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
#include<stdio.h>
int main() {
char buf[1001];
int i, len;
while (gets(buf) != NULL) {
len = strlen(buf);
for (i = len - 1; i >= 0; i--) {
if (buf[i] == ' ') {
buf[i] = 0;
printf("%s ", buf + i + 1);
}
}
printf("%s\n", buf);
}
return 0;
}