文章

84

粉丝

2

获赞

586

访问

23.7k

头像
进制转换2 题解:
P1259 北京大学机试题
发布于2026年2月1日 10:03
阅读数 803

#include<iostream>

using namespace std;

int change(char x) {
	if (x >= '0' && x <= '9') return x - '0';
	else return x - 'A' + 10;
}

int main() {
	
	string s;
	while (cin >> s) {
		int ans = 0;
		for (int i = 2; i < s.size(); i ++ ) {
			ans = ans * 16 + change(s[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发