题解 | #句子逆序#
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
#include <stdio.h> #include <string.h> int main() { char table1[1001]; char table2[1001]; memset(table2, 0x00, sizeof(table2)); memset(table1, 0x00, sizeof(table1)); gets(table1); while(1){ char *pSpace = strrchr(table1,' '); if(pSpace == NULL) break; strcat(table2, pSpace); *pSpace = 0; } strcat(table2, " "); strcat(table2, table1); printf("%s\n",table2+1); return 0; }