标签:void out size names int 时机 space 股票 std
#include "stdafx.h"
#include<iostream>
using namespace std;
#include<vector>
int maxProfit(vector<int> & prices)
{
int n = prices.size();
if (n <= 1)
return 0;
int max =0;
for (int i = 1,min=prices[0];i < n ;i++) {
int Dvalue=prices[i] - min;
if ( Dvalue > max)
max = Dvalue;
if (prices[i] < min)
min = prices[i];
}
return max;
}
void main()
{
vector<int>prices;
int B[]={3,2,3,1,2,12 };
for(int i=0;i<6;i++)
{
prices.push_back(B[i]);
}
int p=maxProfit(prices);
cout<<p;
}
标签:void out size names int 时机 space 股票 std
原文地址:http://www.cnblogs.com/123zzq/p/6517150.html