我怎么用方块?例如下面的计算:
2^4=16
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,结果是:6是否有任何用于此计算的库而不使用乘法?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int c,a=2,b=4;
c=a^b;
printf("%d",c);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
以及如何在C中使用激进?
在C中,^ 是XOR运算符.2 XOR 4确实是平等的6.
您应该包含math.h头文件:
#include <math.h>
double pow( double base, double exp );
...
x = pow(2, 4);
Run Code Online (Sandbox Code Playgroud)