判断奇数偶数
2016-05-24 09:50
211 查看
// 现代流行的"程序员"
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);
}
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);
}
相关文章推荐
- 如何在 Linux/Windows/MacOS 上使用 .NET 进行开发
- 如何在 Linux 中安装微软的 .NET Core SDK
- Mootools 1.2教程 函数
- autoit InputBox 函数
- 文件遍历排序函数
- C#.NET获取拨号连接的宽带连接方法
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页
- C#.Net ArrayList的使用方法
- ASP下经常用的字符串等函数参考资料
- PostgreSQL教程(五):函数和操作符详解(1)
- DOS批处理 函数定义与用法
- asp Chr 函数 数字转字母的方法
- Lua中的函数精讲笔记
- Lua中的闭合函数、非全局函数与函数的尾调用详解
- Lua中调用C++函数示例
- Lua实现split函数
- Lua常用时间函数使用实例
- Lua函数与字符串处理简明总结
- Lua学习笔记之表和函数
- Lua中实现sleep函数功能的4种方法