| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
problem2871,测试数据都已通过,还是WA.亟盼指正,有劳了!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator