#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int n;
while(cin>>n)
{
for(int i=0;i<n;i++)
{
double a,b;
cin>>a>>b;
double x;
x=a>b?(a-b):(b-a);
double y;
y=x/a*100;
if(a>b)
{
if(y>=7)
{
cout<<"-"<<fixed<<setprecision(2)<<y;
cout<<"% dispose"<<endl;
}
else
{
cout<<" -"<<fixed<<setprecision(2)<<y;
cout<<"% keep"<<endl;
}
}
else
{
if(y>=10)
{
cout<<fixed<<setprecision(2)<<y;
cout<<"% dispose"<<endl;
}
else
{
cout<<" "<<fixed<<setprecision(2)<<y;
cout<<"% keep"<<endl;
}
}
}
}
return 0;
}
#include
#include
using namespace std;
int main(){
int n;
while(cin>>n)
{
for(int i=0;i<n;i++)
{
double a,b;
cin>>a>>b;
double x;
x=a>b?(a-b):(b-a);
double y;
y=x/a*100;
if(a>b)
{
if(y>=7)
{
cout<<"-"<<fixed<<setprecision(2)<<y;
cout<<"% dispose"<<endl;
}
else
{
cout<<" -"<<fixed<<setprecision(2)<<y;
cout<<"% keep"<<endl;
}
}
else
{
if(y>=10)
{
cout<<fixed<<setprecision(2)<<y;
cout<<"% dispose"<<endl;
}
else
{
cout<<" "<<fixed<<setprecision(2)<<y;
cout<<"% keep"<<endl;
}
}
}
}
return 0;
}
您的答案為: 8.98% keep 正確答案為: 8.99% keep
應該是四捨五入的問題
#include
#include
using namespace std;
int main(){
int n;
while(cin>>n)
{
for(int i=0;i<n;i++)
{
double a,b;
cin>>a>>b;
double x;
x=a>b?(a-b):(b-a);
double y;
y=x/a*100;
if(a>b)
{
if(y>=7)
{
cout<<"-"<<fixed<<setprecision(2)<<y;
cout<<"% dispose"<<endl;
}
else
{
cout<<" -"<<fixed<<setprecision(2)<<y;
cout<<"% keep"<<endl;
}
}
else
{
if(y>=10)
{
cout<<fixed<<setprecision(2)<<y;
cout<<"% dispose"<<endl;
}
else
{
cout<<" "<<fixed<<setprecision(2)<<y;
cout<<"% keep"<<endl;
}
}
}
}
return 0;
}
您的答案為: 8.98% keep 正確答案為: 8.99% keep
應該是四捨五入的問題
浮點數誤差