ITeye博客

递归 倒序输出

smallearth · 2012-03-10 17:07 · Markdown

输入类是abcd的字符串,要求使用递归实现反转字符串,使输出结果为dcba

#include "stdafx.h"

#include<iostream>
#include<time.h>
using namespace std;
void D(int);
int main()
{

cout<<char(100)<<" "<<char(99)<< " "<<char(98)<<" "<<char(97)<<endl;

cout<<clock()<<endl;
return 0;

}

void D(int n )
{
char i;

if(n==97)

{i='a';}

else
i=char(n-1)+1;

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。