唐老狮if语句练习题

自己私下联系记录

using System;

namespace lessen_if
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("if语句");
            // 输入今天看了多少视频,打印离成功又近了一步、
            int m = 60;
            Console.WriteLine("你今天看了多长时间视频呢");
            int s = int.Parse(Console.ReadLine());
            if (s >= m)
            {
                Console.WriteLine(String.Format("今天看了{0}分钟视频距离成功又近一步", s));
            }
            else 
            {
                Console.WriteLine("加油");
            }
            
            //输入语文,数学,英语,满足条件打印非常棒
            Console.WriteLine("输入英文成绩");
            int Englist = int.Parse(Console.ReadLine());
            Console.WriteLine("输入语文成绩");
            int yuwen = int.Parse(Console.ReadLine());
            Console.WriteLine("输入数学成绩");
            int shuxue = int.Parse(Console.ReadLine());
            if (yuwen > 70 && shuxue > 80 && Englist > 90)
            {
                Console.WriteLine("非常棒继续加油");
            }
            else if (yuwen == 100 || shuxue == 100 || Englist == 100)
            {
                Console.WriteLine("非常棒继续加油");
            }
            else if (yuwen > 90 && shuxue > 70 || Englist > 70)
            {
                Console.WriteLine("非常棒继续加油");
            }
            else
            {
                Console.WriteLine("再接再厉");
            }
            
            //定义变量成绩考的好给100
            int seiseki = int.Parse(Console.ReadLine());
            int kane = 0;
            if (seiseki > 90)
            {
                kane += 100;
                Console.WriteLine(String.Format("爸爸给了{0}块钱", kane));
            }
            //如果a和b加起来大于100或者可以整除就输出a 否则输出b
            Console.WriteLine("输入第一个数");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("输入第二个数");
            int b = int.Parse(Console.ReadLine());                      
            if (a % b == 0 || b % a == 0 || a + b > 100)
            {
                Console.WriteLine(a);
            }
            else
            {
                Console.WriteLine(b);
            }
            //输入整数,偶数打印 your input is even 奇数打印,your input is odd
            
            Console.WriteLine("输入第一个任意数");
            int a1 = int.Parse(Console.ReadLine());
            if (a1 % 2 == 0)
            {
                Console.WriteLine(" your input is even");
            }
            else
            {
                Console.WriteLine("your input is odd");
            }
            //三个整形变量,输入最大的值
            int a2 = int.Parse(Console.ReadLine()),a3 = int.Parse(Console.ReadLine()),a4 = int.Parse(Console.ReadLine());
            if (a2 >= a3 && a2 >= a4)
            {
                Console.WriteLine(a2);
            }
            else if (a2 <= a3 && a3 <= a4)
            {
                Console.WriteLine(a4);
            }
            else
            {
                Console.WriteLine(a3);
            }
            //是数字返回数字,不是数字返回这不是数字字符
            try
            {
                Console.WriteLine("输入1位任意字符");
                int i1 = int.Parse(Console.ReadLine());
                if (i1 <= 9 && i1 >= 0)
                {
                    Console.WriteLine(i1);
                }
                else
                {
                    Console.WriteLine("输入数字大于1位数");
                }
            }
            catch
            {
                Console.WriteLine("这不是一个数字");
            }
            //用户输入账号密码
            Console.WriteLine("输入账号");
            String str = Console.ReadLine();
            if (str == "admin")
            {
                Console.WriteLine("输入密码");
                int i = int.Parse(Console.ReadLine());
                if (i != 8888)
                {
                    Console.WriteLine("密码错误");
                }
                else
                {
                    Console.WriteLine("登陆成功");
                }
            }
            else
            {
                Console.WriteLine("账号不存在");
            }
            //大于18可以查看,小于13不可查看

            Console.WriteLine("您的年龄");
            int i5 = int.Parse(Console.ReadLine());
            if (i5 <= 18 && i5 >= 13)
            {
                Console.WriteLine("是否继续查看输入 yes 或 no");
                String str1 = Console.ReadLine();
                if (str1 == "yes")
                {
                    Console.WriteLine("欢迎查看");
                }
                else
                {
                    Console.WriteLine("退出");
                }
            }
            else if (i5 > 18)
            {
                Console.WriteLine("欢迎查看");
            }
            else 
            {
                Console.WriteLine("禁止查看");
            }
                            

        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值