题目要求:
实现M进制到N进制的转换,注意当单个字符超过9时,要使用16进制数表示,例如,将十进制数10转化为16进制数,则表示为A。
解题思路:
首先将M进制转化为10进制,再将10进制转化为N进制,注意超过9数字转换就可以。
实现代码
/*
进制数转换:实现M进制到N进制的转换,输出可表示为16进制
QiYe005 2016.9.16
*/
#include<string>
#include<iostream>
#include<algorithm>
#include<exception>
#include<assert.h>
using namespace std;
/*
练习编写自定义异常并尝试抛
*/
class MyExceptionStringEmpty:std::exception
{
virtual const char* what() const throw()
{
return"输入数组为空!";
}
}myExceptionStri