在c++中某个数的次幂不能用^表示,因为^在C++中的作用是位异或(XOR)
c++中次幂的表示用pow函数,注意使用前要包含cmath头文件
#include<iostream>
#include<cmath>
int main()
{
double a;
int b;
pow(a,b);
}
pow(a,b)表示的意思是a的b次幂,注意此处的a一定要为double类型。
在c++中某个数的次幂不能用^表示,因为^在C++中的作用是位异或(XOR)
c++中次幂的表示用pow函数,注意使用前要包含cmath头文件
#include<iostream>
#include<cmath>
int main()
{
double a;
int b;
pow(a,b);
}
pow(a,b)表示的意思是a的b次幂,注意此处的a一定要为double类型。