close
標題:
發問:
想用c 搵equation 「x四次-20x-5=0」入面既x值 要點做? main () { double x=0;y; y=pow(10*x+2),1/3); while (x!=y) { x+=0.000001; } printf("x is %d\n", x); } 更新: 應該係::: main () { double x=0;y; y=pow(20*x+5),1/4); while (x!=y) { x+=0.000001; } printf("x is %d ", x); } 更新 2: (我將你個precise 轉左做back.c) 我在xterm 打 「gcc -o back -lm back.c」 個xterm話 「back.c: in function " main ": back.c:14 warning: return type of " main " is not " int "」
最佳解答:
main () { double x=0; double y; while (y != 0) { y=pow(20*x+5, 0.25); x+=0.000001; } printf(”x is %d ”, x); } // Use 0.25 or (float) 1/4, because 1/4 = 0 and (float) 1/4 = 0.25 2006-10-29 23:24:15 補充: Actually the pow part doesn't work as pow(-1, 0.5) is complex and C cannot handle that. 2006-10-30 00:10:01 補充: An alternative way to do the calculation, fat faster than your brute force method:http://ravenkinghand.netfirms.com/precise.zip 2006-10-30 00:11:29 補充: The beginning part of the program (to prevent plagiarism)//To find the solution of x^4 - 20x - 5 = 0#include #include #define PRECISE_MAX100#define START_X-50.0double calcPrecise(double, double);double calcResult(double);
其他解答:
此文章來自奇摩知識+如有不便請留言告知
C program - 搵equation的x值發問:
想用c 搵equation 「x四次-20x-5=0」入面既x值 要點做? main () { double x=0;y; y=pow(10*x+2),1/3); while (x!=y) { x+=0.000001; } printf("x is %d\n", x); } 更新: 應該係::: main () { double x=0;y; y=pow(20*x+5),1/4); while (x!=y) { x+=0.000001; } printf("x is %d ", x); } 更新 2: (我將你個precise 轉左做back.c) 我在xterm 打 「gcc -o back -lm back.c」 個xterm話 「back.c: in function " main ": back.c:14 warning: return type of " main " is not " int "」
最佳解答:
main () { double x=0; double y; while (y != 0) { y=pow(20*x+5, 0.25); x+=0.000001; } printf(”x is %d ”, x); } // Use 0.25 or (float) 1/4, because 1/4 = 0 and (float) 1/4 = 0.25 2006-10-29 23:24:15 補充: Actually the pow part doesn't work as pow(-1, 0.5) is complex and C cannot handle that. 2006-10-30 00:10:01 補充: An alternative way to do the calculation, fat faster than your brute force method:http://ravenkinghand.netfirms.com/precise.zip 2006-10-30 00:11:29 補充: The beginning part of the program (to prevent plagiarism)//To find the solution of x^4 - 20x - 5 = 0#include #include #define PRECISE_MAX100#define START_X-50.0double calcPrecise(double, double);double calcResult(double);
其他解答:
文章標籤
全站熱搜
留言列表