题解 P1427 【小鱼的数字游戏】
0AND1STORY
2019-01-25 21:06:01
其实这道题也有其他的解法,比如说
# 递归
题目中是将一列数按照倒序输出,以0结尾很容易就想到将0作为递归的结束条件,然后递归输入输出即可~~,这样就能做到不用数组流装X的目的~~
代码如下:
```cpp
#include <cstdio>
using namespace std;
inline void dfs_read()
{
register int x;
scanf("%d", &x);
if (!x) return;
dfs_read();
printf("%d ", x);
}
int main()
{
dfs_read();
return 0;
}
```