码迷,mamicode.com
首页 > 其他好文 > 详细

牛老师第二次作业

时间:2015-10-06 10:17:29      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

 

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();

                }
            }
        }
    }

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

技术分享

牛老师第二次作业

标签:

原文地址:http://www.cnblogs.com/yintaiping/p/4856709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!