Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class hello {
- private static int adjacentElementsProduct(int[] inputArray) {
- int sum = inputArray[0] * inputArray[1];
- for (int index = 1; index <= inputArray.length - 1; ++index) {
- final int product = inputArray[index] * inputArray[index + 1];
- if (product >= sum)
- sum = product;
- }
- return sum;
- }
- public static void main(String[] args) {
- int[] numo = {3, 6, -2, -5, 7, 3};
- int h = hello.adjacentElementsProduct(numo);
- System.out.println(h);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement