• C#第四章学习代码


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._1_表达式
    {
        class Program
        {
            static void Main(string[] args)
            {
                //int a = 10;
                //int b = 5;
                //int c = a + b;
                //Console.WriteLine(c);
                //Console.ReadKey();
    
                Console.WriteLine("请输入您的语文成绩");
                double Chinese = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("请输入您的数学成绩");
                double math = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("您的总分是{0}分,您的平均分是{1}分",math+Chinese,(math+Chinese)/2);
                Console.ReadKey();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._2数学运算符
    {
        class Program
        {
            static void Main(string[] args)
            {
                //int a = 5;
                //int b = 3;
                //int c = a %b;
                //int d = +a;
                //int e = -a;
                ////double    d = 5.0;
                ////double e = 3.0;
                ////double f = d/ e;
                //Console.WriteLine("d的值是{0},e的值是{1}",d,e);
    
                int var1 = 10;
                int var2;
                var2 = var1++;//var2=10,var1=11
                Console.WriteLine(var1);
                Console.WriteLine(var2);
    
    
                var2 = ++var1;//var1=12 var2=12
                Console.WriteLine(var1);
                Console.WriteLine(var2);
    
    
    
                Console.ReadKey();            
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._3赋值运算符
    {
        class Program
        {
            static void Main(string[] args)
            {
                int var1 = 10, var2 = 7;
                var1 += var2;
                Console.WriteLine("var1 = 10, var2 = 7,那么var1+=var2的值是{0}", var1);
                var1 = 10;
                var2 = 7;
                var1 -= var2;
                Console.WriteLine("var1 = 10, var2 = 7,那么var1-=var2的值是" + var1);
                var1 = 10;
                var2 = 7;
                var1 *= var2;
                Console.WriteLine("var1 = 10, var2 = 7,那么var1*=var2的值是" + var1);
                var1 = 10;
                var2 = 7;
                var1 /= var2;
                Console.WriteLine("var1 = 10, var2 = 7,那么var1/=var2的值是" + var1);
                var1 = 10;
                var2 = 7;
                var1 %= var2;
                Console.WriteLine("var1 = 10, var2 = 7,那么var1%=var2的值是" + var1);
    
    
    
                Console.ReadKey();
    
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._4关系运算符
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                bool mybool;
                int a = 5;
                int b = 3;
                mybool = a == b;
                Console.WriteLine(mybool);
    
                Console.ReadKey();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._5布尔运算符
    {
        class Program
        {
            static void Main(string[] args)
            {
                bool var1 = true;
                bool var2 = true;
                Console.WriteLine(var1|var2);
    
                //int a = 10;
                //int b = 15;
                //Console.WriteLine((10==a++)||(16==b--));
                //Console.WriteLine("a的值是{0},b的值是{1}",a,b);
                //||运算符前一个操作数为true值时,不再计执行后一个操作数的内容
    
    
    
                Console.ReadKey();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._6位运算符
    {
        class Program
        {
            static void Main(string[] args)
            {
                int num1 = 4;
                int num2 = 1;
                Console.WriteLine(num1>>num2);
                Console.ReadKey();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._7_其他运算符
    {
        class Program
        {
            static void Main(string[] args)
            {
                //string str1 = "我的名字叫";
                //string str2 = "雪上行者";
                //string str3 = str1 + str2;
                //Console.WriteLine(str3);
                //Console.WriteLine("我是用于输出到屏幕" + "这个是利用加号进行连接的");
                // Console.ReadKey();
    
                //int a = 10;
                //double b = 3.14;
                //string c = "我要自学网";
                //bool mybool = false;
                //mybool = a is int;
                //Console.WriteLine("a is int	"+mybool);
                //mybool = b is double;
                //Console.WriteLine("b is double	"+mybool);
                //mybool = c is string;
                //Console.WriteLine("c is string	"+mybool);
                //Console.ReadKey();
                //// 	跳到下一个制表位
    
                //输出语句“I have 数量 pen”
    
    
                //Console.WriteLine("请输入您拥有的钢笔数量");
                //int qty = Convert.ToInt32(Console.ReadLine());
    
    
                //Console.WriteLine("I have {0} pen{1}",qty,qty>1?"s":"");
    
                //判定用户输入的数字与5的关系
    
                Console.WriteLine("请您输入需要比较的数");
                int num = Convert.ToInt32(Console.ReadLine());
                string str=num>=5?"大于等于":"小于";
                Console.WriteLine("您输入的数字{0}5",str);
    
                Console.ReadLine();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._8运算符的优先级
    {
        class Program
        {
            static void Main(string[] args)
            {
                int var1 = 3;
                bool mybool = false;
                mybool = (var1 <= 4) && (var1 >= 2);
                Console.WriteLine(mybool);
                Console.ReadKey();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _4._9本章小结及任务实施
    {
        class Program
        {
            static void Main(string[] args)
            {
                //1232855秒是几天几小时几分几秒
                Console.WriteLine("请输入您想要计算的秒数");
                int time = Convert.ToInt32(Console.ReadLine());
                int day = time / (24 * 3600);
                int hour = time % (24 * 3600) / 3600;
                int min = time % 3600 / 60;
                int sec = time % 60;
                Console.WriteLine("{0}秒是{1}天{2}小时{3}分钟{4}秒",time,day,hour,min,sec);
                Console.ReadKey();
    
            }
        }
    }
  • 相关阅读:
    贝叶斯公式由浅入深大讲解—AI基础算法入门
    再谈前端HTML模板技术
    再谈angularJS数据绑定机制及背后原理—angularJS常见问题总结
    mac版chrome升级到Version 65.0.3325.18后无法打开百度bing搜狗
    图说js中的this——深入理解javascript中this指针
    web app响应式字体设置!rem之我见
    【2020-04-18】 加班
    【2020-04-06】汇郡海下的沉思
    【2020-03-28】Dubbo源码杂谈
    【2020-03-21】Dubbo本地环境搭建-实现服务注册和消费
  • 原文地址:https://www.cnblogs.com/zqyo2000z/p/5338756.html
Copyright © 2020-2023  润新知