<pre name="code" class="cpp">
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int x,y,c;
cout<<"请输入两个数:"<<endl;
cin>>x>>y;
c=pow( x, y);
cout<<"x^y="<<c<<endl;
return 0;
}
本文介绍了一个简单的 C++ 程序,该程序利用标准库中的 pow 函数实现两个整数之间的幂运算。用户输入两个整数 x 和 y 后,程序将计算 x 的 y 次方,并输出结果。
<pre name="code" class="cpp">
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int x,y,c;
cout<<"请输入两个数:"<<endl;
cin>>x>>y;
c=pow( x, y);
cout<<"x^y="<<c<<endl;
return 0;
}
494
722

被折叠的 条评论
为什么被折叠?