Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
70176 李琥博 十进制转R进制 C++ Accepted 1 MS 268 KB 502 2024-04-13 17:51:12

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; char p(int k){ if(k>=0 && k<=9){ return k+'0'; }else{ return 'A'+k-10; } } int main(){ int t=0,n,r,s=0; char a[100]={0}; cin>>n; cin>>r; if(n==0){ cout<<0<<endl; return 0; } while(n){ t=n%r; a[s++]=p(t); n/=r; } a[s]='\0'; for(int i=s-1;i>=0;i--){ cout<<a[i]; } return 0; }