检查是否增加10 c ++

时间:2017-04-17 14:18:53

标签: c++ modulus

我需要检查一个数字是否增加10(70,20,110)

例如: 输入:(74,21,105) 输出:false

输入:(70,20,110) 输出:true

我试过了 function findLinkInText(regex, contentBlock, callback) { const text = contentBlock.getText(); let matchArr, start; if ((matchArr = regex.exec(text)) !== null) { start = matchArr.index; var URL = matchArr[0]; console.log(URL); // I am putting the parameters used to make the call in a JSON object to be used in the "then" var myparameters = { myCallback: callback, URL: URL, start: start }; axios({ method:post, url:'/url', data: { url: URL }, // note that i am attaching the callback to be carrired through myParameters: myparameters }).then(response => { // This section is the callback generated by the post request. // it cannot see anything unless they declared globally or attached to the request and passed through // which is what i did. passit = response.data var s = response.config.myParameters.start; var u = response.config.myParameters.URL response.config.myParameters.myCallback(s, s + u.length) }) } }

1 个答案:

答案 0 :(得分:2)

remainder operator (%)确实是你正在寻找的。

  

二元运算符%产生第一个操作数除以第二个的余数(在通常的算术转换之后)。

您正在寻找的余数是,而不是一个。因此,正确的检查是:

if(num % 10 == 0)