#include<iostream>
usingstd::cin;
usingstd::cout;
intmain()
{
//局部对象
intbase, exponent;
longresult=1;
//读入底数和指数
cout<< "Enter base and exponent:" << endl;
cin>> base >> exponent;
if(exponent < 0) {
cout<< "Exponent can't be smaller than 0" << endl;
return-1;
}
if(exponent > 0) {
//计算底数的指数次方
for(int cnt = 1; cnt <= exponent; ++cnt)
result*= base;
}
cout<< base
<<" raised to the power of "
<<exponent << ": "
<<result << endl;
return0;
}