Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
324694 黄浙峰老师 【C6-3】十六进制转二进制 C++ 通过 100 1 MS 264 KB 394 2025-05-31 14:05:28

Tests(2/2):


#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; int a; string h, x; if(s[0]=='0'){ cout<<0; return 0; } int l=s.size(); for(int i=0; i<l; i++){ h=""; if(s[i]<='9') a=s[i]-'0'; else a=s[i]-'A'+10; for(int j=0; j<4; j++){ h=char(a%2+'0')+h; a=a/2; } x+=h; } while(x[0]=='0') x.erase(0,1); cout<<x; return 0; }


测评信息: