本乘方算法,只能计算整数long范围内乘方,主要是练习信号处理
#include#include using std::cin;using std::cout;using std::endl;long pows(long base,long time);int main(){ long t1,t2; for (;;) { try { cout<<"Please input the base number and how many times it is multiplied?"< <<"example:8 13."< >t1>>t2; if (cin) cout< < >tmp_test; if (cin&&tmp_test=='n') break; } catch (std::range_error err_ra) { cout< < max) { throw std::length_error("Too big a number"); } else { sum*=base; } } return sum; }}