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

标签 java arrays

问题陈述:

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/

相关文章:

java - PermGen 空间内存泄漏

java - 字符串数组拆分而不删除

java - 如何在 Java 中检查二维数组是否占对角线

Java 分数计数器与类

arrays - 查找一组数组中常见的元素集

arrays - 将数组与排序数组进行比较,选择第一个元素

java - 在 java 中建立到 MS Access 数据库的 SQL 连接时找不到合适的驱动程序

java - Java VM 如何处理 MT 上下文中的缓存行和内存对齐?

java - java中的方程中的括号使用正确吗?

java - mybatis中如何调用oracle函数