Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
314 张宸瑞 十进制转R进制 C++ Accepted 0 MS 264 KB 507 2022-08-05 18:14:43

Tests(10/10):


Code:

#include <iostream> #include <string> #include <cmath> using namespace std; char zhuanhuan(int a) { if(a<=9&&a>=0){ return a+'0'; } if(a>=10&&a<=15){ return 'A'+a-10; } } int main() { int x,R,i=0,j=0; char b[100]; cin>>x>>R; if(x==0){ cout<<x; } while(x) { b[i]=zhuanhuan(x%R); x=x/R; i++; } for(j=i-1;j>=0;j--){ cout<<b[j]; } return 0; }