Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
48626 | 舒晨扬 | 十进制转R进制 | C++ | Accepted | 0 MS | 272 KB | 703 | 2023-06-10 15:43:16 |
//include<bits/stdc++.h>erase #include<iostream> #include<string> int a[330]; using namespace std; int main(){ //freopen(a.in,"r",stdin); //freopen(b.out,"w",stdout); int n,r; cin >> n >> r; if(n == 0) { cout << "0"; } else{ int c = 0,t = n;; while(t != 0){ a[c] = t % r; t /= r; c++; } for(int i = c - 1;i >=0;i--){ if(a[i] == 10){ cout << 'A'; } else if(a[i] == 11){ cout << 'B'; } else if(a[i] == 12){ cout << 'C'; } else if(a[i] == 13){ cout << 'D'; } else if(a[i] == 14){ cout << 'E'; } else if(a[i] == 15){ cout << 'F'; } else cout << a[i]; } } return 0; }