Re: [問題]Dev C++當中pow函數的使用

看板Programming作者 (sjgau)時間18年前 (2007/11/08 12:42), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/5 (看更多)
// by Dev-C++ 4.9.9.2 #include <stdio.h> #include <stdlib.h> /* x1= 8.000000, x1= 8.000000, x1= 8.000000, 請按任意鍵繼續 . . . */ int main(int argc, char *argv[]) { double x1,x2,x3; x1= pow(2,3); // 不接受,因為都是整數,沒有pow(int, int),可以理 解 x2= pow((float)2,3.0); // 不接受,因為沒有pow(float, double)的定義 x3= pow(2,3.0); // 但是這個卻接受,不過並沒有pow(int, double)的定 義啊? printf("x1= %.6lf, x1= %.6lf, x1= %.6lf, \n", x1, x2, x3); system("PAUSE"); return 0; } ※ 引述《BoHann.bbs@bbs.cis.nctu.edu.tw (延宕的人生)》之銘言: : 請問一下: : 目前我用Dev C++來寫程式,想使用pow函數,在cmath裡面找到他的定義是 : pow(double, double) //刮號內是指資料型態 : 並且有下面幾種定義 : pow(float, float) : pow(long double, long double) : pow(double, int) : pow(float, int) : pow(long double, int) : 不過寫程式可以發現 : pow(2,3); 不接受,因為都是整數,沒有pow(int, int),可以理解 : pow((float)2,3.0); 不接受,因為沒有pow(float, double)的定義 : pow(2,3.0) 但是這個卻接受,不過並沒有pow(int, double)的定義啊? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.77.241.2
文章代碼(AID): #17CfFCKn (Programming)
文章代碼(AID): #17CfFCKn (Programming)