#include "stdafx.h"#include "math.h"using namespace System;using System;double f(double x){x=(2-pow(double(2.7182818),x))/10;return (x);}int main(array<System::String ^> ^args){int n=1;double x;Console::WriteLine("公式為 : e^x+10*x-2");Console::WriteLine("迭代式為 : x'=(2-e^x)/10");do{Console::WriteLine("請輸入x(0~1) : ");x=Convert.ToDouble(Console::ReadLine());}while(x<0.0||x>1.0);while((f(x)-x)*(f(x)-x)>=0.0005*0.0005){x=f(x);n+=1;}Console::WriteLine("結果為 : ",x);Console::WriteLine("計算次數 : ",n);Console::ReadLine();Console::ReadLine();return 0;}我想要讓X得到我輸入的值 x=Convert.ToDouble(Console::ReadLine());這句應該改成什么?或者改動什么地方?
1 回答

偶然的你
TA貢獻1841條經驗 獲得超3個贊
double x=double.Parse( Console.ReadLine().ToString());
Convert.ToDouble好像不是這么用的吧...
- 1 回答
- 0 關注
- 169 瀏覽
添加回答
舉報
0/150
提交
取消