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.
除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!