题解 | #数字颠倒# 对于顺序-‘栈’或者‘队列’

数字颠倒

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

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

int main() {
    long input;
    cin >> input;
    if(input == 0){
        cout << '0' << endl;
        return 0;
    }
    queue<string> st;
    int tmp = input;
    while(tmp > 0){
        int t = tmp % 10;
        st.push(to_string(t));
        tmp /= 10;
    }
    while(!st.empty()){
        cout << st.front();
        st.pop();
    }
    cout << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

白火同学:大二有这水平很牛了,可以适当对关键信息加粗一点,比如关键技术、性能指标之类的。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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