gpt4 book ai didi

java - 请帮我解决关于数组的 Java 作业

转载 作者:行者123 更新时间:2023-12-01 17:36:46 25 4
gpt4 key购买 nike

问题陈述:

Given an array of ints, compute if the array contains somewhere a value followed in the array by that value times 10. We'll use the convention of considering only the part of the array that begins at the given index.The initial call will pass in index as 0.

示例:

公共(public) boolean 数组220(int[] nums,int索引)

array220({1, 2, 20}, 0) → true
array220({3, 30}, 0) → true
array220({3}, 0) → false**

我陷入了这个问题,没有办法解决它。

最佳答案

for (int i = index; i < nums.length - 1; i++) 
if (nums[i] * 10 == nums[i + 1]) return true;
return false;

关于java - 请帮我解决关于数组的 Java 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5502927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com