我是不是感觉自己把功能做得太强大了
查看原帖
我是不是感觉自己把功能做得太强大了
1213524
C_plus_plus_12345楼主2024/11/26 21:55
#include<iostream>
using namespace std;
void TurnData(int n, int a);
unsigned long long V; 
int f;
char ttfif[90] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 
				  'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 
				  'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 
				  'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 
				  'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 
				  'y', 'z', '@', '_', '+', '!', '#', '{', '}', '"', 
				  ':', ';', '%', '^', '&', '*', '[', ']', '(', ')', 
				  '\\', '`', '~', '\'', '=', '<', '>', ',', '.', '?', 
				  '/', '\xa2', '\xa5', '\xb1', '\xac', '\xb7', '\xa9', '\xd7', '\xf7', '\xa7'};
int main()
{
	cin >> V >> f;
	TurnData(V, f);
	return 0;
}
void TurnData(int n, int a)
{
	int x[17], i, j, k = 0;
	if (n < 0)
	{
		cout << "-";
	}
	j = abs(n);
	do
	{
		k++;
		i = j % a;
		j /= a;
		x[k] = i;
	}
	while (j != 0);
	for (int h = k; h >= 1; --h)
	{
		if (x[h] < 10)
		{
			cout << x[h];
		}
		else
		{
			cout << ttfif[x[h] - 10];
		}
	}
	cout << endl;
}
2024/11/26 21:55
加载中...