第一节 练习14
程序员文章站
2022-04-04 11:11:09
...
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
int n,oldIntAll,oldIntOk,newIntAll,newIntOk;
float oldE,newE;
cout << "输入:";
cin >> n;
cin >> oldIntAll >> oldIntOk;
oldE = oldIntOk * 1.0 / oldIntAll; //升级浮点除
for (int i=1;i<=(n-1);i++){
cin >> newIntAll >> newIntOk;
newE = newIntOk * 1.0 / newIntAll; //升级浮点除
if(newE-oldE > 0.05){
cout << "better" << endl;
}else if(oldE - newE > 0.05){
cout << "worse" << endl;
}else{
cout << "same" << endl;
}
}
return 0;
}
//cout << "输入:";
结果:
上一篇: 第六节 练习3
下一篇: 一行单词字符串完成从小到大的排序