作业帮 > 数学 > 作业

求高手帮我做个简单的VB程序

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:数学作业 时间:2024/05/08 07:10:20
求高手帮我做个简单的VB程序
Divide the number with 2.Convert the result to an integer.Multiply this integer with 2.If the product is equal to the original number,it is an even number,otherwise it is an odd number.
To convert a number to an integer you can use the function int(x) which returns the integer part of a value x.
求高手帮我做个简单的VB程序
大体伪代码框架如下
y = int(x);
if(y/2*2 == y)
even()
else
odd()
另,这算法好傻,最快判断奇偶的话,只需要看整数的最后1位是0还是1就行了(因为计算机用的是二进制数)