第三题: public static int maxProfit(int[] prices) { // write code here int max=0,start = prices[0], stop = prices[0],x=0,y=0; for (int i = 0; i < prices.length; i++) { if (prices[i] < start) { start = prices[i]; stop = prices[i]; x=i; y=i; } if (prices[i]>stop){ stop = prices[i]; y=i; } max = stop-start>max?stop-start:max; } return max; }