标签:str void sort bre sys div class array ati
public static void main(String[] args) { int a[] = new int[]{2,4,6,8,3}; Arrays.sort(a); //2 3 4 6 8 int b = 12; int j = a.length - 1; for (int i = 0; i <= j; ) { if (a[i] == b) { System.out.println(a[i]); break; } if (a[j-1] == b) { System.out.println(a[j-1]); break; } if (a[i] + a[j] == b) { System.out.println(a[i]+"和"+a[j]); break; } if (a[i]+a[j] < b) { i++; continue; } if (a[i]+a[j] > b) { j--; continue; } } }
标签:str void sort bre sys div class array ati
原文地址:https://www.cnblogs.com/fenghua/p/9109125.html