using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace p4_1
{
class Program
{
static void Main(string[] args)
{
double x1 = 1.0 / 0;
double x2 = -1.0 / 0;
double x3 = 0.0 / 0;
Console.Write("1.0/0={0};",x1);
Console.Write("-1.0/0={0};",x2);
Console.WriteLine("0.0/0={0};", x3);
BasicCompute(0, x1);
BasicCompute(0, x2);
BasicCompute(0, x3);
BasicCompute(x1, x1);
BasicCompute(x1, x2);
}
static void BasicCompute(double x1,double x2)
{
Console.Write("{0}+{1|={2};", x1, x2, x1 + x2);
Console.WriteLine("{0}-{1}={2};", x1, x2, x1-x2);
Console.Write("{0}*{1}={2};", x1, x2, x1 * x2);
Console.WriteLine("{0}/{1}={2}\n", x1, x2, x1 / x2);
}
}
}“System.FormatException”类型的未经处理的异常出现在 mscorlib.dll 中。其他信息: 输入字符串的格式不正确。
这个是什么情况啊?我的代码跟书上一样,就出了个这问题,请大神们指教!
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace p4_1
{
class Program
{
static void Main(string[] args)
{
double x1 = 1.0 / 0;
double x2 = -1.0 / 0;
double x3 = 0.0 / 0;
Console.Write("1.0/0={0};",x1);
Console.Write("-1.0/0={0};",x2);
Console.WriteLine("0.0/0={0};", x3);
BasicCompute(0, x1);
BasicCompute(0, x2);
BasicCompute(0, x3);
BasicCompute(x1, x1);
BasicCompute(x1, x2);
}
static void BasicCompute(double x1,double x2)
{
Console.Write("{0}+{1|={2};", x1, x2, x1 + x2);
Console.WriteLine("{0}-{1}={2};", x1, x2, x1-x2);
Console.Write("{0}*{1}={2};", x1, x2, x1 * x2);
Console.WriteLine("{0}/{1}={2}\n", x1, x2, x1 / x2);
}
}
}“System.FormatException”类型的未经处理的异常出现在 mscorlib.dll 中。其他信息: 输入字符串的格式不正确。
这个是什么情况啊?我的代码跟书上一样,就出了个这问题,请大神们指教!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货