当前位置:网站首页>Results fill in the blanks for beer and drinks
Results fill in the blanks for beer and drinks
2022-07-28 07:01:00 【White mouse zero】
Beer per pot 2.3 element , Beverage cans 1.9 element . Xiao Ming bought some beer and drinks , A total of flowers. 82.3 element .
We also know that he buys fewer beers than drinks , Please calculate how many cans of beer he bought .
Be careful : The answer is an integer .
answer
11
The problem solving process
A very regular topic , It should be noted that floating point numbers here are :abs( actual value - The value of comparison )<1e-n .
Attach code
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double p_price,y_price;
int x,y;
for(x=0;x<=38;x++)
{
for(y=0;y<=44;y++)
{
if(x<y)
{
p_price=x*2.3;
y_price=y*1.9;
if(abs(p_price+y_price-82.3)<1e-8)
cout<<x<<endl;
}
}
}
return 0;
}
边栏推荐
- DNS域名解析服务
- Centos7 deploy MySQL database server
- iptables防火墙
- Custom components -- styles
- Which is the best air conduction Bluetooth headset? Air conduction Bluetooth headset ranking
- Technology sharing | sending requests using curl
- Applet navigator cannot jump (debug)
- VSphere esxi 7.0 update 3 release notes
- raid磁盘阵列
- Software testing (concept)
猜你喜欢
随机推荐
[learning notes] linked list operation
shell脚本——“三剑客”之awk命令
搭建PHP7私有仓库
Ubuntu MySQL setting remote access permissions
技术分享 | 如何模拟真实使用场景?mock 技术来帮你
Difference between process and thread
PKU-2524-Ubiquitous Religions(并查集模板)
测试面试题集锦(五)| 自动化测试与性能测试篇(附答案)
Custom component -- pure data field & component life cycle
[learning notes] VIM editor
Technology sharing | sending requests using curl
Vmware workstation configuration net mode
shell脚本——正则表达式
Network - network layer
[learning notes] drive
MySQL installation and use
iptables防火墙
Custom component -- data listener
单元测试框架Jest搭配TypeScript的安装与配置
Which brand of air conduction earphones is good and highly praised







