我在编程竞赛中遇到过这个问题,但找不到答案,谁能帮我解决这个问题???
Input<<string
Output<<reverse(string)
约束:不允许循环,必须使用内置函数!
最佳答案
使用递归:
#include <stdio.h>
void print_reversed(const char* str) {
if (*str) {
print_reversed(str + 1);
printf("%c", *str);
}
}
int main() {
print_reversed("abcdef");
printf("\n");
}
关于c - 如何在不使用 C 中的内置函数和循环的情况下打印字符串的反转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15553265/