当前位置:网站首页>[code hoof set novice village question 600] operator / type conversion in different operation sequences
[code hoof set novice village question 600] operator / type conversion in different operation sequences
2022-07-19 13:38:00 【Sandm *】
Topic link :
Their thinking :
For the calculation formula given in the topic :
The trap involves operators / Characteristics of ,
That is, it is required that at least one side of both sides is of floating-point type ,
For the whole expression (a * x + (a+x) / (4a))
Because the whole has braces ,
therefore 1.0 / 2 The result of the floating-point type obtained will not be multiplied by it first ,
Instead, the program first calculates the result in braces ,
If this is not the case / When the value type on both sides changes , Then the calculation will be wrong
This is also one of the traps
Reference code :
#include<bits/stdc++.h>
using namespace std;
int main( )
{
int x = 0,a = 0;
//char str = '0';
//cin >> x >> a;
scanf("%d %d",&x,&a);
float end = 0;
end = (1.0/2.0)*(a*x+(a+x)/(4.0*a));
printf("%.2f",end);// Don't forget %
return 0;
}Don't forget the %
边栏推荐
- [Yugong series] July 2022 go teaching course 012 forced type conversion
- [pyGame learning notes] 6 Cursor mouse cursor
- CMOS switch learning (I)
- codeforce:A. Difference Operations【数学思维】
- onvif协议相关:4.1.1 WS-Username token方式获取WSUsernameTokenBean
- LeetCode 0118. Yanghui triangle
- Hello, everyone. How to synchronize binlog in real time before the database starts? Is there a good scheme
- Atmospheric non isohalo effect
- Attachment handling of SAP Fiori
- The latest Jilin construction safety officer simulation question bank and answers in 2022
猜你喜欢

torch.utils.data.DataLoader说明

【码蹄集新手村 600 题】运算符 / 在不同的运算顺序中的类型转换

【码蹄集新手村 600 题】格式化的输入输出,使用 0 来代替补全的空格

codeforce:A. Doremy‘s IQ【反向贪心】

onvif协议相关:4.1.1 WS-Username token方式获取WSUsernameTokenBean

How to upgrade Flink job gracefully?
![Codeforce:a. doremy's IQ [reverse greed]](/img/3d/065f9f1cbd857d324b6ed074d1afbf.png)
Codeforce:a. doremy's IQ [reverse greed]

Simulation of overvoltage protection (OVP) circuit based on PMOS
![[Tencent blue whale] the seventh 7.24 operation and maintenance day holiday greetings ~ come and make a wish~](/img/60/ab96abd599230078b19abad0aecba2.png)
[Tencent blue whale] the seventh 7.24 operation and maintenance day holiday greetings ~ come and make a wish~

Forget about postman. Apifox is better
随机推荐
Running node for getting started with eth
[pumpkin Book ml] (task2) mathematical derivation of linear model (least squares estimation, generalized Rayleigh quotient, maximum likelihood estimation, etc.)
【码蹄集新手村 600 题】科学计数法的实现方式,输出指数形式
[learn FPGA programming from scratch -53]: high level chapter - FPGA development based on IP core - principle and configuration of PLL PLL IP core (Xilinx)
[pyGame learning notes] 5 Collision detection of rect objects
响应式织梦模板酒窖类网站
Li Kou 198-213 looting Ⅰ, Ⅱ - Dynamic Planning
ArrayList underlying analysis
sqli-labs(less-11)
How to upgrade Flink job gracefully?
Responsive Zhimeng template logistics and freight service website
STM32F1与STM32CubeIDE编程实例-MPU-6050 六轴(陀螺仪 + 加速度计)驱动
【码蹄集新手村 600 题】float 与 double 的格式说明符
Flutter uses animatedswitcher to switch scenes
Ossimport migration path
onvif协议相关:3.1.2 Digest方式获取token列表
Li Kou's 302 weekly match
[pyGame learning notes] 7 event
Transphorm's surface mount packaging product series adds industry standard to-263 (D2Pak) packaging products to expand the advantages of supergan platform
Force buckle 64 minimum path sum -- Introduction to dynamic programming