mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-27 08:26:20 +00:00
43 lines
582 B
Markdown
43 lines
582 B
Markdown
|
# 6-2 递归实现顺序输出整数
|
||
|
|
||
|
本题要求实现一个函数,对一个整数进行按位顺序输出。
|
||
|
|
||
|
### 函数接口定义:
|
||
|
```c++
|
||
|
void printdigits( int n );
|
||
|
```
|
||
|
函数`printdigits`应将`n`的每一位数字从高位到低位顺序打印出来,每位数字占一行。
|
||
|
|
||
|
### 裁判测试程序样例:
|
||
|
```c++
|
||
|
#include <stdio.h>
|
||
|
|
||
|
void printdigits( int n );
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int n;
|
||
|
|
||
|
scanf("%d", &n);
|
||
|
printdigits(n);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
/* 你的代码将被嵌在这里 */
|
||
|
```
|
||
|
|
||
|
### 输入样例:
|
||
|
```in
|
||
|
12345
|
||
|
```
|
||
|
|
||
|
### 输出样例:
|
||
|
```out
|
||
|
1
|
||
|
2
|
||
|
3
|
||
|
4
|
||
|
5
|
||
|
```
|