math庫中有pow(x,y)函數,x為底數,y為指數,返回值為結果,如下:
#include <stdlib.h>
#include <math.h>
#include<iostream>
using namespace std;
int main() {
int x, y, result;
cout<<"Enter x,y \n"<<endl;
cin>>x>>y;
result=pow(x,y);
cout<<"\nthe result is:"<<result<<endl;
system("pause");
return 0;
}