注册 登录
编程论坛 新人交流区

大家来看看,该如何填这空格?

c的fans 发布于 2007-11-03 07:35, 292 次点击
输入一个四位数(正整数),将各位数字分开,并按其反序输出.如输入3456,则输出6543,要求用递归函数实现.
#include <iostream.h>
void f(int n)
{
____________________;//输出
if(n/10)
____________________;//递归调用
}
void main()
{
int x,num;
cout < < "input a number: ";
cin> > x;
cout < < "the new number is: ";
f(x);
cout < <endl;
}
3 回复
#2
huaipupua2007-11-03 08:55
bu zhidao

#3
Lotus_Hypnos2007-11-03 09:11
#include <iostream.h>
void f(int n)
{
cout <<(n%10);//输出
if(n/10)
f(n/10);//递归调用

}

void main()
{
int x,num;
cout << "input a number: ";
cin>> x;
cout << "the new number is: ";
f(x);
cout <<endl;
}
#4
济南的雪2007-11-03 10:19
LS说的是正确的啊
1