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 |
格式有一点点问题,改了ACIn Reply To:菜鸟求助.... Posted by:snailly18 at 2006-07-21 16:33:07 #include<iostream> #define MAX 1000 using namespace std; void main() { int a[MAX]; int i=1; do { cin>>a[0]; int n=0; int cup=0,cdown=0; int up=0,down=0; int flag=-1; int t=0; if(a[0]==0) break; i=1; do scanf("%d",&a[i]); while(a[i++]!=0); n=i-1; for(i=1;i<n;i++) { if(a[i-1]<a[i]) { cup=1; flag=0; break; } if(a[i-1]>a[i]) { cdown=1; flag=1; break; } } for(i=1;i<n;i++) { if(a[i-1]<a[i]) { up++; if(flag==1) cup++; flag=0; } if(a[i-1]>a[i]) { down++; if(flag==0) cdown++; flag=1; } if(a[i-1]==a[i]) { if(flag==0) up++; if(flag==1) down++; } } if(cup==0) cup=1; if(cdown==0) cdown=1; printf("Nr values = %d: %f %f\n",n,float(up)/cup,float(down)/cdown); }while(1); } 输出的格式有问题,少了“: ” 把这句话 printf("Nr values = %d %f %f\n",n,float(up)/cup,float(down)/cdown); 改为 printf("Nr values = %d: %f %f\n",n,float(up)/cup,float(down)/cdown); 就OK了 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator