早教吧作业答案频道 -->数学-->
求高手帮我做个简单的VB程序Dividethenumberwith2.Converttheresulttoaninteger.Multiplythisintegerwith2.Iftheproductisequaltotheoriginalnumber,itisanevennumber,otherwiseitisanoddnumber.Toconvertanumbertoani
题目详情
求高手帮我做个简单的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.
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.
▼优质解答
答案和解析
大体伪代码框架如下
y = int(x);
if(y/2*2 == y)
even()
else
odd()
另,这算法好傻,最快判断奇偶的话,只需要看整数的最后1位是0还是1就行了(因为计算机用的是二进制数)
y = int(x);
if(y/2*2 == y)
even()
else
odd()
另,这算法好傻,最快判断奇偶的话,只需要看整数的最后1位是0还是1就行了(因为计算机用的是二进制数)
看了 求高手帮我做个简单的VB程序...的网友还看了以下:
已知字母组合成英语单词1、e e t t i n h r 2、e e r a t w h 3、o 2020-05-14 …
设有关系R、S和T如下图所示,则元组演算表达式{t|(u)((R(u)∨S(u))∧(v)(T(v) 2020-05-26 …
设有关系R、S和T如下所示,则元组演算表达式{t| (u)((R(u)∨S(u))∧(v)(T(v) 2020-05-26 …
6.同济高数书例题,刚体以等角速度w绕L轴旋转,就刚体上一点M的线速度.由|v|=|w||r|si 2020-06-12 …
6..同济高数书例题,刚体以等角速度w绕L轴旋转,就刚体6.同济高数书例题,刚体以等角速度w绕L轴 2020-06-12 …
如果令A、B、C、D……X、Y、Z这26个英文字母,分别等于百分之1、2、3、4、……HARDWO 2020-07-09 …
matlab求解二阶导数方程,四个方程四个未知量>>symst>>E=32;G=10.81;b=2 2020-07-19 …
询问~~关於这两个单词的发音~waht[hwɑt]~和where[hwɛr]百度词典裏的发音是美音 2020-07-23 …
具有相同电子层结构的五种微粒:X+、Y2+、W、Z2-、R-,下列分析不正确的是[]A.原子序数:Y 2020-11-26 …
如果令A、B、C、D……X、Y、Z这26个英文字母,分别等于百分之1、2、3、4、……HARDWOR 2021-02-09 …