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

使用方法做要求输入第一个数字大于第二个数字

时间:2015-05-10 17:05:55      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

       static void Main(string[] arr)
        {
            int[] shuZi;
            
            bool bj = false;
            while (!bj)
            {
                shuZi = Test();
                bj = BiJiao(shuZi[0], shuZi[1]);
                  }
            Console.WriteLine("ok");
            Console.ReadKey();
        }

        public static int[] Test()
        {
            int n1=0;
            int n2=0;
            try
            {
                Console.WriteLine("请输入数字1");
                n1 = ZhuanHuan();
                Console.WriteLine("请输入数字2");
                n2 = ZhuanHuan();

            }
            catch
            {
                Console.WriteLine("请输入正确的数字");
                Test();
            }
            int[] intSz=new int[2];
            intSz[0]=n1;
            intSz[1]=n2;
            return intSz;
            
        }
        public static int ZhuanHuan()
        {
            int numbers = Convert.ToInt32(Console.ReadLine());
            return numbers;
        }

        public static bool BiJiao(int n1, int n2)
        { 
            bool bj=false;
            if (n1 > n2)
            {
                bj = true;
            }
            return bj;
        }

 

使用方法做要求输入第一个数字大于第二个数字

标签:

原文地址:http://www.cnblogs.com/zywf/p/4492344.html

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