用maxn和minn分别记录最大值和最小值,用最大值减最小值,看差是否在1e-8即可
请看AC代码:
1 #include<cstdio> 2 #include<iostream> 3 4 using namespace std; 5 6 int main() 7 8 { 9 double a, b; 10 cin >> a >> b; 11 double maxn = max(a,b);//取最大值 12 double minn = min(a,b);//取最小值 13 if(maxn-minn <= 1e-8) cout<<"yes"<<endl;//判断误差 14 else cout<<"no"<<endl; 15 return 0; 16 17 }