Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

郁闷!!

Posted by v11 at 2011-01-29 19:54:36 on Problem 1492
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator