zoukankan      html  css  js  c++  java
  • 牛老师第二次作业

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

                    }
                }
            }
        }

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

  • 相关阅读:
    Do you want a timeout?
    [整]常用的几种VS编程插件
    [转]Windows的窗口刷新机制
    [整][转]Invoke和BeginInvoke的使用
    [整]C#获得程序路径
    [转]Visual Studio 2010 单元测试目录
    飞秋的实现原理
    面向对象的七大原则
    [转]玩转Google开源C++单元测试框架Google Test系列
    [转]C#中的Monitor类
  • 原文地址:https://www.cnblogs.com/yintaiping/p/4856709.html
Copyright © 2011-2022 走看看