PATA1027题解

#include<iostream>
#include<math.h>
using namespace std;
const int INF = 1e9;
const int MAXN = 3*1e5;
int cost[MAXN], val[MAXN];
int N, num, a, b; 
int convert(int x) {
    int z[40], num = 0;
    do{
        z[num++] = x % 13;
        x = x/13;
    }while(x!=0);
    char tempA, tempB;
    if(z[0] >= 10) tempA = z[0]-10 +'A';
    else tempA = '0' + z[0];
    if(z[1] >= 10) tempB = z[1]-10 +'A';
    else tempB = '0' + z[1];
    if(num == 1) cout << "0" << tempA;
    else cout << tempB << tempA;
}
int main() {
    
        cout << "#";
    int a = 3;
    while(a--) {
        cin >> num;
        convert(num);
    }
}

进制的转换

上一篇:java实现第六届蓝桥杯三羊献瑞


下一篇:python中继承