FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/src/main/java/com/thealgorithms/maths/FindMin.java at master · tyb/Java · GitHub
tyb
/
Java
Public
forked from
TheAlgorithms/Java
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
src
/
main
/
java
/
com
/
thealgorithms
/
maths
/
FindMin.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (34 loc) · 949 Bytes
Breadcrumbs
Java
/
src
/
main
/
java
/
com
/
thealgorithms
/
maths
/
FindMin.java
Copy path
File metadata and controls
41 lines (34 loc) · 949 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package
com
.
thealgorithms
.
maths
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
Random
;
public
class
FindMin
{
/**
* Driver Code
*/
public
static
void
main
(
String
[]
args
) {
Random
random
=
new
Random
();
/* random size */
int
size
=
random
.
nextInt
(
100
) +
1
;
int
[]
array
=
new
int
[
size
];
/* init array with random numbers */
for
(
int
i
=
0
;
i
<
size
;
i
++) {
array
[
i
] =
random
.
nextInt
() %
100
;
}
assert
Arrays
.
stream
(
array
).
min
().
getAsInt
() ==
findMin
(
array
);
}
/**
* Find the minimum number of an array of numbers.
*
* @param array the array contains element
* @return min value
*/
public
static
int
findMin
(
int
[]
array
) {
int
min
=
array
[
0
];
for
(
int
i
=
1
;
i
<
array
.
length
; ++
i
) {
if
(
array
[
i
] <
min
) {
min
=
array
[
i
];
}
}
return
min
;
}
}
Back
|
FazBrowse Home
|
New Git URL