题解 | #进制转换#

进制转换

https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6

#include <iostream>
using namespace std;

int main() {
    char ch;
    int result = 0;
    cin>>ch;
    cin>>ch;
    while (cin>>ch){
        result *= 16;
        if (ch >= '0' && ch <='9')
            result += ch -'0';
        else
            result += ch - 'A' + 10;
    }
    cout<<result;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务