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 drownever at 2006-12-21 20:43:44 on Problem 2833
#include<iostream.h>
#include<stdio.h>
int main()
{
	long nl,ng,n;
	long array[5000000];
	scanf("%d %d %d",ng,nl,n);
	for(int v=0;v<n;v++)
		scanf("%d",&array[v]);
	while(nl!=0&&ng!=0&&n!=0)
	{
		for(int i=0;i<n;i++)
			for(int j=i;j<n;j++)
			{
				if(array[i]>array[j])
				{
					long temp=array[i];
					array[i]=array[j];
					array[j]=temp;
				}
			}
        long sum=0;   //init and updata ,continue,,,,,
		for(int e=nl;e<n-ng;e++)
			sum=sum+array[e];
		sum=sum/(n-ng-nl);
		//output result.
	    printf("%0.6f\n",sum); 
		//get new data for input .
		scanf("%d %d %d",ng,nl,n);
	    for(int b=0;b<n;b++)
	    	scanf("%d",&array[b]);
	}
	return 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