有点晚了,直接暴力写法吧

#include<stdio.h>

int main(){

char word[1000];
scanf("%[^\n]\n", word);
int lenth = 0;
for (; word[lenth] != '\0'; lenth++);
int i = lenth -1;
for (; i>=0; i--){
    if(word[i]== ' '){
        for (int x =i+1; x<lenth; x++){
            printf("%c", word[x]);
        }
        printf(" ");
        lenth =i;
    }
}
for (int x =0; x<lenth; x++){
            printf("%c", word[x]);
        }
return 0;

}