码迷,mamicode.com
首页 > 其他好文 > 详细

2017.4.20实验三:5、写一个递归函数,将给定的字符串按逆序输出。(要求逆序的字符串在主调函数中输出)

时间:2017-05-01 11:58:38      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:out   count   turn   iostream   bcd   pac   clu   str   ret   

#include <iostream>
using namespace std;
void Invert(char arr[],int &i,char str[])
{
if(arr[i]==‘\0‘)
return;
else
{
str[i]=arr[i];
i++;
Invert(arr,i,str);
}
}
int main ()
{
char arr[]="abcdef";
int count=0,i;
char str[20];
Invert(arr,count,str);
for(i=count-1;i>=0;i--)
cout<<str[i];
cout<<endl;
return 0;

}

2017.4.20实验三:5、写一个递归函数,将给定的字符串按逆序输出。(要求逆序的字符串在主调函数中输出)

标签:out   count   turn   iostream   bcd   pac   clu   str   ret   

原文地址:http://www.cnblogs.com/linxiaojie517/p/6791529.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!