Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
143118 | C班詹皓杰 | 十进制转d进制 | C++ | 通过 | 100 | 0 MS | 252 KB | 344 | 2024-04-12 22:38:57 |
#include<iostream> #include<stack> using namespace std; stack<char> s; char to(int x){ if(x>=0 && x<=9){ return char(x+'0'); }else{ return char('A'+(x-10)); } } int main(){ int n,d; cin>>n>>d; do{ s.push(to(n%d)); n /= d; }while(n > 0); while(!s.empty()){ cout<<s.top(); s.pop(); } return 0; }