我该如何回答这个问题?被卡住了好几个小时!!!! [英] How do I answer this? Been stuck on it for hours!!!!
本文介绍了我该如何回答这个问题?被卡住了好几个小时!!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
写一个函数isMultipleOf的定义,它接收两个整数参数,如果第一个参数是第二个参数的倍数,则返回true。否则返回false。
因此,如果参数是27和8,则函数返回false,因为27不是8的倍数。但是如果参数是34并且17函数返回true,因为34是17的倍数(2 * 17是34)。
解决方案
你想要的是模数(%
)运营商。
http ://www.cprogramming.com/tutorial/modulus.html [ ^ ]
Write the definition of a function isMultipleOf , that receives two integer arguments and returns true if the first argument is a multiple of the second. Otherwise false is returned.
So, if the arguments are 27 and 8 the function returns false because 27 is not a multiple of 8. But if the arguments are 34 and 17 the function returns true because 34 is a multiple of 17 (2*17 is 34).
解决方案
What you want is the modulus (%
) operator.
http://www.cprogramming.com/tutorial/modulus.html[^]
这篇关于我该如何回答这个问题?被卡住了好几个小时!!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文