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

why WA ?

Posted by syh791180600 at 2010-04-22 14:59:18 on Problem 2555
各位大虾,小弟刚接触ACM,这一题不知错哪了,能不能给小弟看一下,谢谢了
#include <iostream>
#include <iomanip>
#define CW 4.19
#define CI  2.09 
#define em 335
using namespace std ;
int main()
{
	float mw = 0 , mi = 0 ;
	float tw = 0 , ti = 0 ;							  
	float t_finnal = 0 ;
	while (cin >> mw >> mi >> tw >> ti)
	{
		if (mw == 0 && mi == 0 && tw == 0 && ti == 0)
		{
			break ;
		} 
		else
		{
			if (ti < 0)
			{
				if ((mw * tw * CW) >= (mi * (- ti) * CI + mi * em))
				{
					t_finnal = (mw * CW * tw - mi * em + mi * CI * ti) / (mi  * CW + mw * CW ) ;
					cout << "0.0 g of ice and " <<fixed << setprecision(1) << mw + mi <<" g of water at " <<
						fixed << setprecision(1) << t_finnal << " C" << endl ; 
				}
				else if ((mw * tw * CW) < (mi * (- ti) * CI + mi * em))
				{
					if (mw * CW * tw >= mi * (- ti) * CI)
					{
						cout << fixed << setprecision(1) << mi - ((mw * CW * tw + mi * ti * CI) / em)
							<<" g of ice and " <<fixed << setprecision(1) <<mw + ((mw * CW * tw + mi * ti * CI) / em) 
							<< " g of water at 0.0 C" << endl ;
					}
					else if (mw * CW * tw < mi * (- ti) * CI)
					{
						t_finnal = (mw * CW * tw + mw * em + mi * CI * ti) / (mi * CI + mw * CI) ;
						cout << fixed <<setprecision(1) << mi + mw << " g of ice and " << "0.0 g of water at " 
							<< fixed << setprecision(1) << t_finnal << " C" << endl ;
					}
				}
			}
			else if (ti == 0)
			{
				if (mw * CW * tw >= mi * em)
				{
					t_finnal = (mi * CW * tw - mi *em) / (mw * CW + mi * CW) ;
					cout << "0.0 g of ice and "	<< fixed << setprecision(1) << mi + mw 
						<< " g of water at " <<setprecision(1) <<t_finnal << " C" << endl ;
				} 
				else
				{
					cout << fixed << setprecision(1) << mi - (mw * CW * tw ) / em 
						<< " g of ice and " << setprecision(1) << mw + (mw * CW * tw ) / em 
						<< " g of water at 0.0 C" << endl ;
				}
			}
		}
	}
	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