Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Add Index of max number in an array
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int[] arr={6,-5,9,-7,9}; int max=arr[0],idx=0; for(int i=1;i<arr.length;i++){ if(arr[i]>max){ idx=i; max=arr[i]; } } for(int i:arr){ System.out.println(i+idx); } } }
run
|
edit
|
history
|
help
0
Decode byte array
Umang Khambhalikar
MinMaxArray
Rabbits in forest (leetod)
Basic Matrix
anonymous abstract class
3.c
post decrement
Round Price
2c