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; }
【C++】求解指数
最新推荐文章于 2025-02-04 14:18:58 发布