Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
75423 | 邓昊源 | 十进制转R进制 | C++ | Accepted | 0 MS | 272 KB | 842 | 2024-05-26 17:40:16 |
#include<bits/stdc++.h> using namespace std; int main(){ double n; cin >> n; int r; cin >> r; int s[32]; int sum = 0; int z = n; double x = n - z; while(z!=0){ int y = z % r; s[sum] = y; sum++; z/=r; } if( sum == 0){ cout << "0"; } for(int i = sum - 1;i >= 0;i--){ if(s[i] < 10){ cout << s[i]; }else{ if(s[i] == 10){ cout << 'A'; } if(s[i] == 11){ cout << 'B'; } if(s[i] == 12){ cout << 'C'; } if(s[i] == 13){ cout << 'D'; } if(s[i] == 14){ cout << 'E'; } if(s[i] == 15){ cout << 'F'; } } } if( x != 0){ cout << "."; }else{ return 0; } for(int i = 0;i < 9;i++){ x = x * r; int xz = x; cout << xz; x = x - xz; if(x == 0){ break; } } return 0; }