题解 | #进制A+B#
进制A+B
https://www.nowcoder.com/practice/6187581174ac48278ca3bccf8d534897
#include <stdio.h> int turn(int x) { int yua; int goal = 0; int power = 1; yua = x; while (yua) { int s = yua % 16; goal += power * s; power *= 16; yua /= 16; } return goal; } int turn1(int y) { int yua1; int goal1 = 0; int power1 = 1; yua1 = y; while (yua1) { int s1 = yua1 % 16; goal1 += power1 * s1; power1 *= 16; yua1 /= 16; } return goal1; } int main() { int a, b; while (scanf("%x", &a) != EOF && scanf("%o", &b) != EOF) { int c = turn(a); int d = turn1(b); printf("%d",c + d); } return 0; }