#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
while(n--)
{
double m,p;
cin>>m>>p;
double qq,aa;
qq=(p-m);
qq/=m;
qq*=100;
aa=qq*100;
if(aa>0)aa=floor(aa+0.5);
else if(aa<0)aa=ceil(aa-0.5);
aa/=100;
cout<<fixed<<setprecision(2)<<aa<<"% ";
if(qq>=10 || qq<=-7)cout<<"dispose\n";
else cout<<"keep\n";
}
}
// system("pause");
return 0;
}
以上會NA
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
while(n--)
{
double m,p;
cin>>m>>p;
double qq;
float aa;
qq=(p-m);
qq/=m;
qq*=100;
aa=qq*100;
if(aa>0)aa=floor(aa+0.5);
else if(aa<0)aa=ceil(aa-0.5);
aa/=100;
cout<<fixed<<setprecision(2)<<aa<<"% ";
if(qq>=10 || qq<=-7)cout<<"dispose\n";
else cout<<"keep\n";
}
}
// system("pause");
return 0;
}
這個卻AC?