文章

1

粉丝

44

获赞

0

访问

593

头像
进制转换2 题解:
P1259 北京大学机试题
发布于2024年2月29日 23:23
阅读数 593

#include <bits/stdc++.h>
using namespace std;

int main(){
    char s[105];
    while(cin >> s)
        {
        int l = strlen(s), ans = 0;
        for(int i = 2; i < l; i++){
            if(s[i] >= '0' && s[i] <= '9') ans = ans * 16 + (s[i] - '0');
            else ans = ans * 16 + s[i] - 'A' + 10;
            }
        printf("%d\n", ans);
        }
    return 0;
}
 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发