程式碼 Decode() 函數結尾大括號缺失,導致編譯錯誤。核心邏輯與前題相同:逐行讀入、以空白分割單字、反序輸出。
#include <stdio.h>
#include <string.h>
int main() {
int N; scanf("%d\n", &N);
char line[1000];
while (N-- && fgets(line, sizeof(line), stdin)) {
line[strcspn(line, "\n")] = 0;
char* token = strtok(line, " ");
int first = 1;
while (token) {
if (!first) putchar(' ');
for (int i = strlen(token)-1; i >= 0; --i) putchar(token[i]);
first = 0;
token = strtok(NULL, " ");
}
putchar('\n');
}
return 0;
}
補齊大括號、簡化邏輯、移除多餘函數包裝,即可正確編譯執行。