美文网首页
5.1(输入两数 比大小 输出值)

5.1(输入两数 比大小 输出值)

作者: youthisY | 来源:发表于2018-11-01 11:13 被阅读0次

    题目

    要求用户输入两个数a、b,如果a被b整除或者a加b大于100,则输出a的值,否则输出b的值

    代码

     Console.WriteLine("请输入一个数a");
                string a = Console.ReadLine(); 
                int shu1 = Convert.ToInt32(a);
                Console.WriteLine("请输入一个数b");
                string b = Console.ReadLine();
                int shu2 = Convert.ToInt32(b);
    
                if (shu1 % shu2 == 0 || shu1 + shu2 > 100)
                {
                    Console.WriteLine("输出的数为{0}", shu1);
                }
                else
                {
                    Console.WriteLine("输出的数为{1}", shu2);
                }
                Console.ReadKey();
    

    效果图

    image.png

    相关文章

      网友评论

          本文标题:5.1(输入两数 比大小 输出值)

          本文链接:https://www.haomeiwen.com/subject/ygwtxqtx.html