function areTheyInLove(flower1, flower2) { if (flower1 % 2 === 0 && flower2 % 2 !== 0 || flower1 % 2 !== 0 && flower2 % 2 === 0) { return true; } else { return false; } }

// 测试 console.log(areTheyInLove(2, 3)); // true console.log(areTheyInLove(2, 4)); // false console.log(areTheyInLove(1, 3)); // false console.log(areTheyInLove(0, 1)); // true

JavaScript 判断蒂米和莎拉是否相爱 - 花瓣奇偶数算法

原文地址: https://www.cveoy.top/t/topic/mlWR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录