pow函数返回double类型值,想要求余数必须要Int类型,可以自己写一个函数求幂:
int power(int x, int y) {
int product = 1;
if (y == 0) {
product = 1;
}
else {
for (int i = 1; i <= y; i++) {
product *= x;
}
}
return product;
}
pow函数返回double类型值,想要求余数必须要Int类型,可以自己写一个函数求幂:
int power(int x, int y) {
int product = 1;
if (y == 0) {
product = 1;
}
else {
for (int i = 1; i <= y; i++) {
product *= x;
}
}
return product;
}