我必须创建一个返回 b^e 值的函数。这就是我所做的:
#include<stdio.h>
#include<math.h>
int funzione_potenza (int b, int e);
int main ()
{
int b, e, potenza;
printf("Inserisci la base: ");
scanf("%d",&b);
printf("Inserisci l'esponente: ");
scanf("%d",&e);
printf("La potenza e' %d",potenza);
return 0;
}
int funzione_potenza (int b, int e)
{
int potenza;
potenza = pow(b,e);
return potenza;
}
当我运行它时,它显示错误的功率值(例如 5343123) 怎么了?
最佳答案
您不需要函数来调用内置的 pow 函数。如果您尝试编写自己的函数,请尝试使用循环或递归构建解决方案。
关于创建一个返回 pow b^e 的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47056768/