跟着题解写的为啥0蛋求助谢谢啦
查看原帖
跟着题解写的为啥0蛋求助谢谢啦
1272396
huochairenzhishang楼主2024/7/13 11:54
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
using namespace std;
int charch(char c) {
	if (c >= 'A' || c <= 'F')
		return c - 55;
	else if (c > 47 && c < 58)
		return c - 48;
	else if(c=='-')
		return -1;
	return 0;
}
long long read(int n) {
	long long  x = 0;
	char c = '\0';
	c = getchar();
	while (1) {
		if (c != '\n') break;
		c = getchar();
	}
	while (charch(c)) {
		x *= n;
		x += charch(c);
		c = getchar();
		if (c == '\n') break;
	}
	return x;
}
char cfun(int x) {
	if (x < 10)
		return x + 48;
	return x - 10 + 'A';
}
void opfun(int k,int m) {
	if (k == 0) return;
	opfun(k / m,m);
	putchar(cfun(k % m));
	
}
int main() {
	int n; cin >> n;
	long long  x = read(n);
	int m; cin >> m;
	opfun(x, m);
	cout << '\n';
}
2024/7/13 11:54
加载中...