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 00448205 at 2005-03-24 17:03:11 on Problem 1017
# include < iostream.h>
# include < math.h>
int sum ( int []);
int sumary;
int parcelnum[100] = {0} ;
int sum( int a[7])
{
	sumary = 0 ;
	for ( int j = 1; j < 7 ; j ++ )
	sumary += a[j];
	return sumary;
}
void main ()
{
	int  product[7];
	for (  int i = 1 ; i < 7; i ++ )  
		cin >> product[i];
	int j = 0 ;
	int total = sum(product) ; // 如果total 为0 ,说明输入的是6个0 ,结束
	while ( total )
	{
		//放置 4×4 ,5×5 ,6×6
		parcelnum[j] += product[4] + product[5]+ product[6];

		//放置 3×3
		parcelnum[j] += ceil (( product [3] - 0.5 ) /4 );
		
		//放置 2×2
		if ( product[3] % 4 == 0 ) 
		{
			if (product[2] > 5 * product[4] ) 
			 parcelnum[j] += ceil ( ( (product[2] - 5 * product[4]) - 0.5) / 9 ) ;
		}

		else 
		{
			if (product[2] > ( 5 * product[4]  + (4 - product[3] % 4 )* 2 - 1))  
		
			{
				int  left = product[2] - ( 5 * product[4]  + (4 - product[3] %4 )* 2 - 1);
				parcelnum [j]  +=  ceil(  (left - 0.5) / 9   )  ;
			}
		}
		
		//放置 1×1
		if(  product[1] >  ( (parcelnum[j] -  product[6] ) * 36 -  product[5] * 25 
			-  product[4] *16 - product[3] * 9 -  product[2] *4) )
		{
			int left ;
			left = product[1] - ((parcelnum[j] -  product[6] ) * 36 -  product[5] * 25 
			-  product[4] *16 - product[3] * 9 -  product[2] *4) ;
			parcelnum[j] += ceil( (left - 0.5 ) / 36 );
		}
	
		j ++ ;

		for ( i = 1 ; i <7; i ++ ) 
		cin >> product[i];
		total = sum(product) ;
	}
	for ( int k = 0 ; k<j; k ++ )
		
	cout << parcelnum[k] <<endl;
}

		 




	

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