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

problem2871,测试数据都已通过,还是WA.亟盼指正,有劳了!

Posted by 2006141329 at 2007-02-24 19:32:47
#include<iostream.h>
#include<math.h>
main()
{
   double a1,a2;
   int result;
   int b1,b2;
   int i;
   cin>>a1>>a2;
   while (a2!=999)
   {        
	  result=(a2-a1)*100;
	  b1=result/100;     //小数点前数字//
	  b2=(result%100); 	    //小数点后数字//
            if(b2<0 && b2>-10)    //小数点后数字若为负,输出正//
	    cout<<b1<<"."<<"0"<<-b2<<endl;
	  else if(b2<=-10)      //如果测试数据是0.00与-10.05,不加此判断将输出-10.5//
		  cout<<b1<<"."<<-b2<<endl;
	  else if(b2<10)      //小数点后数字为正的情况//
		  cout<<b1<<"."<<"0"<<b2<<endl;
	  else
		  cout<<b1<<"."<<b2<<endl;  //因为是在C++中,为了补足小数点后零位,不得不分开输出//

	  a1=a2; 
	  cin>>a2;
   }
     cout<<"End of Output"<<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