代码实现:

 1 #include<iostream>
 2 using namespace std;
 3 void reverse()
 4 {
 5     char s;
 6     if((s=getchar())!='\n')
 7         reverse();
 8     if(s!='\n')
 9         cout<<s;
10 }
11 void main()
12 {    
13    reverse();
14 }

运行图示:

写一个递归函数reverse(s),将字符串颠倒过来。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
相关资源
相似解决方案