Re: [問題]Dev C++當中pow函數的使用
// 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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 5 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章