📅  最后修改于: 2022-03-11 14:56:26.338000             🧑  作者: Mango
public static void twoLargest(int values[]){
int largestA = values[0];
int largestB = -1;
for(int i = 0; i < values.length; i++){
if(values[i] > largestA){
largestB = largestA;
largestA = values[i];
}
else if (values[i] > largestB && values[i] != largestA) {
largestB = values[i];
}
}
System.out.println("Largest - " + largestA);
System.out.println("2nd largest Largest - " + largestB);
}