当前位置:网站首页>Consolidate -c operator

Consolidate -c operator

2022-07-01 11:58:00 Jinan medical applet champion

  Foundation entry consolidation

#region  Operator  071  The arithmetic   Relationship   Logic  

            //  The arithmetic 
            int suan = 1;
            int suan2 = 2;
            int  suan3 = suan + suan2;

            Console.WriteLine(" Operator arithmetic operator addition calculation :{0}",suan3);

            // Comparison operator   ==  > <

            // ==  Indicates that the results of the operation of the expressions on both sides are equal , Notice that there are two equal signs . 
            //  such as 10 % 2  It's an expression .  0  Alone is an expression , Although only a number . 
            Console.WriteLine("10 Is it an even number ?!:"+ (10 % 2 ==0));
            //   For example, design 1 Expression .  5  Start divination at the third day of August in Xinsi year , The specific divination is as follows : The method of divination : number of years + Monthly number + days , Its sum is divided by eight , Mod , Divide by eight .   Ren   Yin Nian   3 Earth branch numbers  , Lunar calendar 6 month ,  Digital 6, The third day of June .

            // 3+6+3=12  % 8 =   The result is false,  How can I serve true?
            Console.WriteLine(" Residual calculation results :"+(12 % 8 ==0.96));






            //  Logical operators   
            //【 example  2】 Judge  2017  Whether the year is a leap year .
            // According to the title requirements , The judgment of leap year needs to meet one of two conditions , One is that the year can be  4  Integer but cannot be  100  Integers , One is that it can be  400  to be divisible by . The code is as follows .
            Console.WriteLine(" Judge 2017 Whether the year is a leap year ?:"+((2017 % 4 ==0 && 2017 % 100 !=0 ) || (2017 % 400 ==0)));
            Console.WriteLine(" Judge 2018 Whether the year is a leap year ?:" + ((2018 % 4 == 0 && 2018 % 100 != 0) || (2018 % 400 == 0)));
            #endregion

effect

 

 

原网站

版权声明
本文为[Jinan medical applet champion]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207011155254154.html