我正在使用代碼塊學習c。我的代碼是代碼塊電源功能在c中不工作
#include<stdio.h>
#include<math.h>
int main()
{
int x;
x = pow(5,2);
printf("%d", x);
}
Output is 25
,當我使用此代碼
#include<stdio.h>
#include<math.h>
int main()
{
int x,i,j;
printf("please enter first value");
scanf("%d", &i);//5
printf("please enter second value");//2
scanf("%d", &j);
x = pow(i,j);
printf("%d", x);
}
Output is 24
這裏有什麼問題?我只是使用掃描功能獲取價值,並以相同的方式使用pow函數。
適用於我,但您應該在主方法結束時返回0 – cIph3r 2013-02-24 10:52:25
查看[手冊頁](http://linux.die.net/man/3/pow) - pow的原型是'double pow(double x,double y);'。從使用適當的類型開始。 – fvu 2013-02-24 10:53:15
@fvu如果他要求整數值,並且他想要一個整數結果,爲什麼類型「不合適」呢? – junix 2013-02-24 10:55:50