zoukankan      html  css  js  c++  java
  • C#判断奇偶数的函数

    // 现代流行的"程序员"
    public static bool IsOdd(int n) 

        while (true)
        {
            switch (n)
            {
                case 1: return true;
                case 0: return false;
            }
            n -= 2;
        }


    // 中规中矩的程序员 
    public static bool IsOdd(int n)

        return (n % 2 == 1) ? true : false;


    // 有经验的C#程序员 
    public static bool IsOdd(int n)

        return Convert.ToBoolean(n % 2);


    // 汇编程序员 
    public static bool IsOdd(int n)

        return Convert.ToBoolean(n & 1);
    }  

  • 相关阅读:
    leetcode297
    leetcode4
    leetcode23
    leetcode72
    leetcode239
    leetcode42
    leetcode128
    leetcode998
    SAP MM GR-based IV, 无GR不能IV?
    小科普:机器学习中的粒子群优化算法!
  • 原文地址:https://www.cnblogs.com/JulesHello/p/6170449.html
Copyright © 2011-2022 走看看