Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1030551 // indexOfMaxEntryInDoubleArray

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2709L/16K).

1  
static int indexOfMaxEntryInDoubleArray(double[] a) {
2  
  if (empty(a)) ret -1;
3  
  int bestIndex = 0;
4  
  double bestValue = a[0];
5  
  int n = l(a);
6  
  for (int i = 1; i < n; i++) {
7  
    double x = a[i];
8  
    if (x > bestValue) {
9  
      bestIndex = i;
10  
      bestValue = x;
11  
    }
12  
  }
13  
  ret bestIndex;
14  
}

Author comment

Began life as a copy of #1024770

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030551
Snippet name: indexOfMaxEntryInDoubleArray
Eternal ID of this version: #1030551/2
Text MD5: f7e1914237df692dd198a3d7b9b9b962
Transpilation MD5: 76f731283062ad27a4905153dc9c6c7d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-07 17:46:01
Source code size: 303 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 101 / 155
Version history: 1 change(s)
Referenced in: [show references]