Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
WA了,大伙说的我都注意了,为什么还错呢?求解释!!!#include <iostream> using namespace std; int main() { int n,m,k,i,j,buy = 0; double pi[10000],pi_m = 0,pi_n = 0; cin >> m >> n >> k; for(i = 1;i <= k;i++) cin >> pi[i]; for(i = n;i <= k;i++){ double sum_m = 0,sum_n = 0; int count = i; for(j = 0;j < m;j++) sum_m += pi[count--]; sum_n = sum_m; for(j = m;j < n;j++) sum_n += pi[count--]; pi_m = sum_m * 1.0 / m; pi_n = sum_n * 1.0 / n; if(pi_m > pi_n && buy == 0){ cout << "BUY ON DAY " << i << endl; buy = 1; } else if(pi_m <= pi_n && buy == 1){ cout << "SELL ON DAY " << i << endl; buy = 0; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator