/*
*Corpyright (c)2013,烟台大学计算机学院
*All right reseved.
*作者:张梦佳
*完成日期:2013年11月20日
*版本号:v1.0
*输入描述:123
*问题描述:二进制的转换
*程序输出:1111011
*问题分析:
*算法设计:
*/
#include <iostream>
using namespace std;
void f(int n);
int main()
{
int n;
cout<<"请输入一个整数";
cin>>n;
cout<<n<<"对应的二进制数为:";
f(n);
cout<<endl;
return 0;
}
void f(int n)
{
if(n==0)
{
return;
}
else
{
f(n/2);
cout<<n%2;
return;
}
}
感悟
return的用法还是有点迷糊