Menu Close

C语言练习:使用递归函数把一个句子反转

C语言练习:使用递归函数把一个句子反转

#include <stdio.h>
void reverseSentence();
int main() {
    printf("Enter a sentence: ");
    reverseSentence();
    return 0;
}

void reverseSentence() {
    char c;
    scanf("%c", &c);
    if (c != '\n') {
        reverseSentence();
        printf("%c", c);
    }
}

结果:

Enter a sentence: I am a good Guy
yuG doog a ma I
Process returned 0 (0x0) execution time : 8.566 s
Press any key to continue.
除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Leave the field below empty!

Posted in 函数

Related Posts