题解 | #八进制#和二进制一样

八进制

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

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;


int main() {
    stack<int> mystack;
    int n;
    while (scanf("%d", &n) != EOF) {
        //转为8进制
        while (n != 0) {
            int t = n % 8;
            mystack.push(t);
            n /= 8;
        }
        while (!mystack.empty()) {
            int t = mystack.top();
            mystack.pop();
            printf("%d", t);
        }
        printf("\n");
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

06-27 18:45
中山大学 Ruby
25届应届毕业生,来广州2个礼拜了,找不到工作,绝望了,太难过了…
应届想染班味:9爷找不到工作只能说明,太摆了或者太挑了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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