迴圈
輸入
輸出
%數要四捨五入
dispose 和 keep 則是四捨五入前
故,分開處理
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int n;
double m, p, rate1, rate2;
while(cin >> n)
while(n--)
{
cin >> m >> p;
rate1 = (p-m)*100/m;
rate2 = round( (p-m)*10000/m);
rate2 /= 100;
cout << fixed << setprecision(2) << rate2 << "% ";
if(rate1 >= 10.00 || rate1 <= -7.00)
cout << "dispose\n";
else
cout << "keep\n";
}
return 0;
}
全站熱搜
留言列表