题解 | #牛牛逆序输出#
牛牛逆序输出
https://www.nowcoder.com/practice/d981181ce18e4cce945fdf52daf037a1
#include <iostream>
using namespace std;
void reverse(int x) {
if (x) { //当x存在个位数时,进入打印
cout << x % 10; //打印个位数字
reverse(x / 10); //将x除以10,传入递归函数
}
}
int main() {
int n;
cin >> n;
reverse(n);
return 0;
}
查看13道真题和解析