輸入一個英文句子,翻轉句子中單詞的順序,但單詞內字符的順序不變。spa
句子中單詞以空格符隔開。爲簡單起見,標點符號和普通字母同樣處理。code
例如輸入「I am a student.」,則輸出「student. a am I」。io
這個題比較簡單,直接上代碼了(GCC編譯經過)編譯
#include "stdio.h" #include "stdlib.h" void helper(char a[],int n); int main(void) { char str[15] = "I am a student!"; helper(str,15); printf("\n"); return 0; } void helper(char a[],int n) { int e = n-1; int i,j,t; for(i=e;i>=0;i=j-1) { for(j=i;j>=0 && a[j]!=' ' ;--j); t=j+1; while(t<=i) printf("%c",a[t++]); if(j<0) return; else printf(" "); } }