+ 1

Is the array increasing, decreasing, or neither.

Create a method that determines this. Method takes int array. determines if its increase decrease or neither. examples: 1 2 3 would return an int 111 and print out up. 321 would return an int 222 and print out down. 132 would return an int 333 and print out neither. 1223 would return an int 333 and print out neither.

16th Nov 2017, 10:49 PM
Danat Gorth
Danat Gorth - avatar
4 odpowiedzi
+ 4
You can also use Math api. It contains the min and max methods. By the position of the minimum value and the maximum value you can sort in increasing or decreasing array. There's many ways to make this. Take alook in the array class, sort methods...
17th Nov 2017, 3:21 AM
Malkon F
Malkon F - avatar
+ 3
if (array[0] > array[1] && array[2] )&& (array[1] > array[2]) down 222 if (array[0] < array[1] && array[2]) && (array[1] < array[2]) up 111 else neither 333 input 1,2,3 up 111 input 321 down 222 input 312 neither 333 I did not take the test to see if it works (I'm eating lunch). Test please
17th Nov 2017, 3:06 AM
Malkon F
Malkon F - avatar
+ 1
If you have 1 3 5 7 or 2 4 6 8 or 1 2 5 8 or 9 7 3 2 ????
16th Nov 2017, 10:59 PM
Daniel
Daniel - avatar
0
I think I worded my question wrong. My apologies, I figured it out though. Thank you.
17th Nov 2017, 8:29 PM
Danat Gorth
Danat Gorth - avatar