Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
323980 | 董峻昊 | 【C6-2】10进制转D进制 | C++ | 通过 | 100 | 1 MS | 260 KB | 538 | 2025-05-24 13:02:33 |
#include<bits/stdc++.h> using namespace std; string s; int main(){ long long n,d,a; cin>>n>>d; if(d==2){ char c; if(n==0) s="0"; while(n>0){ c=n%2+'0'; s=c+s; n=n/2; } cout<<s; } if(d==8){ char c; if(n==0) s="0"; while(n>0){ c=n%8+'0'; s=c+s; n=n/8; } cout<<s; } if(d==16){ char c; if(n==0) s="0"; while(n>0){ a=n%16; if(a<10){ c=a+'0'; }else{ c=a+'A'-10; } s=c+s; n=n/16; } cout<<s; } return 0; }