我自己写了一个
public class FindNum {
/**
* @param args
*/
public static void main(String[] args) {
int[] intArr = {1,2,3,4,7,11,15};
int sum =15;
int start;
int end;
int i=0;
int j=intArr.length-1;
while(true){
start = intArr[i];
end = intArr[j];
if((start+end)<sum){
i++;
}else if((start+end)==sum){
break;
}else if((start+end)>sum){
j--;
}
}
System.out.println(start+","+end);
}
} |