#include #pragma GCC optimize("Ofast,inline") //将字符串str中的内容反向打印的函数 void reversePrint(char str[]); int main() { char s[100]; scanf("%s", s); reversePrint(s); printf("\n"); return 0; } /* 请在这里填写答案 */ #include #include void reversePrint(char str[]) { if (str == NULL) { return; } if (strlen(str) == 1) { printf("%c", str[0]); } else { char *tmp = malloc(sizeof(char) * strlen(str)); /* Why this: * char *tmp = malloc(sizeof(char) * (strlen(str) - 1)); * doesn't work? */ for (int i = 1, n = strlen(str), j = 0; i < n; i++, j++) { tmp[j] = str[i]; } reversePrint(tmp); free(tmp); printf("%c", str[0]); } }