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 <stdio.h> float pi(float *num,int i,int k) { int j; float sum=0; for(j=i-k+1;j<=i;j++) { sum+=num[j-1]; } return sum/k; } int main(){ int m,n,k; int i,j; float price[10000],pim,pin; int bull=0,bear=0; scanf("%d%d%d",&m,&n,&k); for(i=0;i<k;i++) { scanf("%f",&price[i]); } for(i=n;i<k;i++) { pim=pi(price,i,m); pin=pi(price,i,n); if(pim>pin) { if(i==n) { printf("BUY ON DAY %d\n",i); bull=1; bear=0; } else if(bear==1) { printf("BUY ON DAY %d\n",i); bull=1; bear=0; } else { bull=1; bear=0; } } else { if(i==n) { printf("SELL ON DAY %d\n",i); bear=1; bull=0; } else if(bull==1) { printf("SELL ON DAY %d\n",i); bear=1; bull=0; } else { bear=1; bull=0; } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator