题解 | #牛牛的digit#

牛牛的digit

https://www.nowcoder.com/practice/21b49f1f495f4280b8a96c415deaa3c4

#include <iostream>
using namespace std;

void output(int x, int i)
{
    int d = x % 10;
    if (i == 1)
        cout << d;
    else 
    {
        output(x / 10, i - 1);
        cout << d;
    }
        
}
int main() {
    int x, i;
    cin >> x >> i;
    output(x, i);
     
}
// 64 位输出请用 printf("%lld")

递归的思想输出就行

C++题解 文章被收录于专栏

记录在牛客网用C++刷题的题解思路

全部评论

相关推荐

06-11 13:34
门头沟学院 C++
offe从四面八方来:我真的没时间陪你闹了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务