我有以下 C# 代码:
double eps=0.1, low=1, y0=0, x, y, high, muchlat, answer, ribua;
Console.WriteLine("Enter x");
x = double.Parse(Console.ReadLine());
high = y = x;
muchlat = Math.Abs(y - y0) ;
if (x < 0)
{
Console.WriteLine("X can't be less than zero, press any key to exit");
}
else if (muchlat > eps)
{
while (muchlat > eps)
{
Console.WriteLine(y);
y0 = y;
y = (high + low) /2;
ribua = Math.Pow(y,2);
if (ribua == x)
{
answer = x;
}
else if (ribua > x)
{
high =y;
}
else if (ribua < x)
{
low =y;
}
else if (muchlat < eps)
{
answer = y;
break;
}
}
}
Console.WriteLine(answer);
Console.ReadLine();
当我尝试调试程序时,我收到此消息“使用未分配的局部变量'答案'(CS0165)”,我的问题是如何修复它,问题出在哪里?