[問題] Devc++輸出問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Dec-c++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
sum1輸出的值有問題
如果我要把輸出的數值變成一個OUTPUT檔, 則該怎麼編輯?
餵入的資料(Input):
輸入值=30.4108
預期的正確結果(Expected Output):
when the i=1, follow, x=1, sum1=1.91e-16
when the i=1, follow, x=2, sum1=1.51e-7
when the i=1, follow, x=3, sum1=9.86e-5
錯誤結果(Wrong Output):
when the i=1, follow, x=1, sum1=1.#INF00E+000
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[])
{
int i;
float a;
float b;
double x, sum;
double y, sum1;
double z, sum2;
printf("argc= %d \n", argc);
for (i=0;i<argc;i++) {
printf("i= %d, argv= [%s]\n", i, argv[i]);
}
system("pause");
// ----------------------------------------------------
sum=0.0;
sum1=0.0;
sum2=0.0;
for (i=1;i<argc;i++) {
for (x=1;x<=5;x++){
a= 3.00e+10;
b= 6.626e-34;
sum= a*b*atof(argv[i])/x;
y= exp(sum);
z= exp(-sum);
sum1=y*pow((sum/(z-1)),2);
printf("when the, i= %d, follow, x= %.6lf, sum1= %.6lf\n", i, x, sum1);
}
}
system("pause");
return 0;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.122.142.99
※ 編輯: garyer 來自: 140.122.142.99 (03/21 11:14)
→
03/21 11:23, , 1F
03/21 11:23, 1F
→
03/21 11:23, , 2F
03/21 11:23, 2F
→
03/21 11:27, , 3F
03/21 11:27, 3F
→
03/21 11:28, , 4F
03/21 11:28, 4F
→
03/21 11:29, , 5F
03/21 11:29, 5F
→
03/21 11:32, , 6F
03/21 11:32, 6F
→
03/21 11:33, , 7F
03/21 11:33, 7F
→
03/21 11:33, , 8F
03/21 11:33, 8F
→
03/21 11:34, , 9F
03/21 11:34, 9F
推
03/21 13:41, , 10F
03/21 13:41, 10F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章