CodePudding user response:
Public static void main (String [] args) {
Int [] array=,2,5,7,9 {1};
The Integer result=null;
For (int I=array. The length - 1; I> 0; I -) {
For (int j=I; J>=0; J -) {
Int temp=array [I] - array [j];
If (result==null | | resultResult=temp;
}
}
}
System.out.println(result);
}
CodePudding user response:
Two for loop canInt maxV=Inetger. MIN_VALUE;
for(int i=0; i
}
}
System. The out. Println (maxV);
CodePudding user response:
If is I realize: first to sort an array, and then the maxvalueCodePudding user response:
Public static void main (String [] args) {
Int [] arr={12, 2, 23, 54, 65, 21 and 35};
Int maxValue=https://bbs.csdn.net/topics/0;
int i=0;
Int result;
For (int j=1; J & lt; Arr. Length; J++) {
Result=arr [j] - arr [I];
If (result & gt; MaxValue)
MaxValue=https://bbs.csdn.net/topics/result;
Else if (the result & lt; 0)
I=j;
}
System. The out. Println (maxValue);
}