递归完毕之后不应该是只执行一次cout吗?还有为什么会倒叙输出?(十进制转换二进制递归实现方法)

#include "stdafx.h"

#include "iostream"

using namespace std;

void f(int n);

int _tmain(int argc, _TCHAR* argv[])

{

int a;

cout<<"123123"<<endl;

cin>>a;

if(a==0)

cout<<0<<endl;

else

{

f(a);

}

cout<<endl;

return 0;

}

void f(int n)

{

if(n==0)

{

return;

}

else

{

f(n/2);    //这个是怎么实现的呢?请讲的具体些。最好举个例子

cout<<n%2;

}

}



破晓之饮
浏览 1501回答 1
1回答

asd8532

每退出一次输出一次才是递归啊,之前剩下的也要执行啊
打开App,查看更多内容
随时随地看视频慕课网APP