您的位置:首页 > 其它

牛老师第二次作业

2015-10-06 09:30 357 查看
namespace 第二次作业
{
class RandomNumber
{
public int Add(int x, int y)
{
return x + y;
}
public int Sub(int x, int y)
{
return x - y;
}
public int Mul(int x, int y)
{
return x * y;
}
public int Del(int x, int y)
{
return x / y;
if (y == 0)
{
y = 1;
}

}
class Program
{

static void Main(string[] args)
{
int a, b;

Console.Write("随机输入一个数:");
a = int.Parse(Console.ReadLine());
Console.Write("随机输入另一个数<若有除法此处不能为0>:");
b = int.Parse(Console.ReadLine());
RandomNumber rn = new RandomNumber();
Console.WriteLine("这两个随机数的和是:{0}", rn.Add(a, b));
Console.WriteLine("这两个随机数的差是:{0}", rn.Sub(a, b));
Console.WriteLine("这两个随机数的积是:{0}", rn.Mul(a, b));
Console.WriteLine("这两个随机数的商是:{0}", rn.Del(a, b));
Console.ReadLine();

}
}
}
}

预计用时五小时实际用时三十多小时,做了几十个版本,只有这一个能运行出来,

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: