#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;
}