有什么功能可以告诉我一个数字是奇数还是偶数? [英] is there any function to tell me if a number is odd Or even ?

查看:85
本文介绍了有什么功能可以告诉我一个数字是奇数还是偶数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么功能可以告诉我一个数字是奇数还是偶数?
如果没有,我怎么能自己找到它?

is there any function to tell me if a number is odd Or even ?
if not how can i find it out myself?

推荐答案

难道难道不能写作吗?

Is it that diffcult to write?

public bool IsOdd(int value)
{
    return value % 2 != 0;
}


if (i % 2 == 0)
        {
            //i is Even
        }
        else
        {
            //i is Odd
        }




请显示此
int n1 = 10;
for(int i=0;i<=n1;i++)
{
            if (n1 % 2 == 0)
            {
                Response.Write("This is Even");
            }
            else
            {
                Response.Write("This is Odd");
            }
}


这篇关于有什么功能可以告诉我一个数字是奇数还是偶数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆