牛老师第二次作业
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();
}
}
}
}
预计用时五小时实际用时三十多小时,做了几十个版本,只有这一个能运行出来,
{
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();
}
}
}
}
预计用时五小时实际用时三十多小时,做了几十个版本,只有这一个能运行出来,
相关文章推荐
- OC(实现简单通讯录操作)
- OC(实现中等通讯录的操作)
- Ubuntu文件系统的一些基本命令
- ECShop 去掉配送区域
- OC深坑测试题及其答案
- 创建纯洁的TableViewCell
- Expandablelistview
- OC第六讲(Block,语法糖)
- 活动指示器ActivityIndicatorView和进度条ProgressView
- 关于程序员的笑话
- Plug-in org.eclipse.jdt.ui was unable to load class
- iOS 给UIView、UIImageView、UILabel添加点击事件
- 江湖急救篇:slave 复制错误
- OC第七讲(Category类目)
- UI第一讲(UIView)
- UI第二讲(UILabel)
- 自己封装图片请求,好于SDWebImage,优化了UItableView(上)
- DatePick
- 匈牙利最大匹配+大质数判定 csu1552 Friends
- [LeetCode]: 83: Remove Duplicates from Sorted List