Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
118407 | 江婉儿 | 十进制转d进制 | C++ | 通过 | 100 | 0 MS | 252 KB | 626 | 2023-12-30 10:58:09 |
#include<bits/stdc++.h> #define maxn 1000 using namespace std; int Stack[maxn]; int top=-1; char c[36]={'0','1','2','3','4','5','6','7','8','9', 'A','B','C','D','E','F','G','H','I','J', 'K','L','M','N','O','P','Q','R','S','T', 'U','V','W','X','Y','Z'}; char pop() { return c[Stack[top]]; } bool StackEmpty() { return top<0?1:0; } void push(int value) { Stack[++top]=value; } void conversion(int n,int x) { for(;n;n/=x) push(n%x); while(!StackEmpty()) { cout<<pop(); top--; } } int main() { int n,x; cin>>n>>x; if(n==0) cout<<0; else conversion(n,x); return 0; }