mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +00:00
39 lines
543 B
Markdown
39 lines
543 B
Markdown
# 6-3 十进制转换二进制
|
||
|
||
本题要求实现一个函数,将非负整数n转换为二进制后输出。
|
||
|
||
### 函数接口定义:
|
||
```c++
|
||
void dectobin( int n );
|
||
```
|
||
函数`dectobin`应在一行中打印出二进制的`n`。建议用递归实现。
|
||
|
||
### 裁判测试程序样例:
|
||
```c++
|
||
#include <stdio.h>
|
||
|
||
void dectobin( int n );
|
||
|
||
int main()
|
||
{
|
||
int n;
|
||
|
||
scanf("%d", &n);
|
||
dectobin(n);
|
||
|
||
return 0;
|
||
}
|
||
|
||
/* 你的代码将被嵌在这里 */
|
||
```
|
||
|
||
### 输入样例:
|
||
```in
|
||
10
|
||
```
|
||
|
||
### 输出样例:
|
||
```out
|
||
1010
|
||
```
|