Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
324709 | 王栎州 | 【C6-3】八进制转换二进制 | C++ | 解答错误 | 0 | 1 MS | 256 KB | 356 | 2025-05-31 14:13:44 |
#include<bits/stdc++.h> using namespace std; int n,a,sum=0; int main(){ string s; cin>>s; if(s=="0"){cout<<0; return 0;} int a; string h,x=""; for(int i=1;i<=s.size();i++){ h=""; a=s[i]-'0'; for(int j=1;j<=3;j++){ h=char(a%2+'0')+h; a=a/2; } x+=h; } while(x[0]=='0'){ x.erase(0,1);} cout<<x; return 0; }