题解 | 八进制

八进制

https://www.nowcoder.com/practice/eda051c1effc4dffa630bc8507f0c5f7

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    while (cin >> n) { // 注意 while 处理多个 case
        vector<int>res;
        while(n){
            res.push_back(n%8);
            n/=8;
        }
        for(int i=res.size()-1;i>=0;i--){
            cout<<res[i];
        }
        puts("");
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

03-25 19:00
东北大学 Java
程序员牛肉:太好了,是聊天记录。不得不信了。 当个乐子看就好,不要散播焦虑
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务