进制转换(包括负数,2到16进制)
进制转换
1.进制表
首先建立一个标准进制转化表:
char stand[20] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
2.转化进制
每一次对需要转化的数取余,整除(代码如下):
#include
#include
#include
using namespace std;
char stand[20] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int main()
{
int n,m;
while (scanf("%d %d", &n, &m) != EOF)
{
char a[100] = {0};
bool sign = 0;
if (n < 0)
{
共有 0 条评论