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 |
郁闷!!#include<cstdio> #include<cstring> #include<iostream> int data[10000]; using namespace std; int main() { int n,i,j,k,num; int up,down,same,up_sum,down_sum; while(scanf("%d",&data[0])&&data[0]) { i=1; while(scanf("%d",&data[i])&&data[i]) i++; n=i; up=down=same=up_sum=down_sum=0; for(i=1;i<n;) { while(data[i-1]==data[i]) same++,i++; if(i>=n) break; if(data[i-1]<data[i]) { up_sum+=same,same=0; while(data[i-1]<=data[i]&&i<n) { up_sum+=1; i++; } up+=1; } else { down_sum+=same,same=0; while(data[i-1]>=data[i]&&i<n) { down_sum+=1; i++; } down+=1; } } printf("Nr values = %d: %.6lf %.6lf\n",n,up_sum?1.0*up_sum/up:0,down_sum?1.0*down_sum/down:0); } } 应该没错呀。。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator