提交 1fd608c7 编写于 作者: M Mars Liu

fixed error in exercise max value

上级 db9cf853
...@@ -22,8 +22,11 @@ max(array); ...@@ -22,8 +22,11 @@ max(array);
```java ```java
int max(int[] array){ int max(int[] array){
int result = 0; if(array.length == 0){
for(int i=0;i<array.length;i++){ return 0;
}
int result = array[0];
for(int i=1;i<array.length;i++){
int value = array[i]; int value = array[i];
if(value > result){ if(value > result){
result = value; result = value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册