当前位置:网站首页>Electronic Association C language level 1 34, piecewise function
Electronic Association C language level 1 34, piecewise function
2022-07-04 07:05:00 【dllglvzhenfeng】
Electronics Association C Language 1 level 34 、 Piecewise functions
OpenJudge - 13: Piecewise functions
C++ Code :
/*
Electronics Association C Language 1 level 34 、 Piecewise functions
http://noi.openjudge.cn/ch0104/13/
Programming , Calculate the following piecewise functions y=f(x) Value .
y=-x+2.5; 0 <= x < 5
y=2-1.5(x-3)(x-3); 5 <= x < 10
y=x/2-1.5; 10 <= x < 20
Input
A floating point number N,0 <= N < 20
Output
Output N Corresponding piecewise function value :f(N). Keep the result to three decimal places .
The sample input
1.0
Sample output
1.500
*/
#include<iostream>
using namespace std;
int main()
{
double n,y;
cin>>n;
if(n>=0 && n<5)
{
y=-n+2.5;
}
else
{
if(n>=5 && n<10)
{
y=2-1.5*(n-3)*(n-3);
}
if(n>=10 && n<20)
{
y=n/2-1.5;
}
}
printf("%.3lf\n",y);
return 0;
}
python3 Code :
n = float(input())
if 0 <= n < 5:
print('%.3f' % (2.5 - n))
elif n < 10:
print('%.3f' % (2 - 1.5*(n - 3)*(n - 3)))
elif n < 20:
print('%.3f' % (n/2 - 1.5))
【 Strong base project 】 Some videos of calculus in mathematics and physics competitions
Strong base project Mathematics books recommend
Strong base project Mathematics books recommend _dllglvzhenfeng The blog of -CSDN Blog
NOC C++ National primary and secondary school information technology innovation and practice competition (NOC): Software creative programming track
02 Schedule :
Time signing up :2022 year 1 month -4 month
Tryout time :2022 year 5 month
National finals :2022 year 7 month -8 month ( Time and place to be notified )
2021 year 8 month NOC National primary and secondary school information technology innovation and practice competition Software creative programming primary school senior group Python Analysis of final questions
2022 year 3 Monthly Institute of Electronics Python Grade examination papers ( second level ) Analysis of the answer
边栏推荐
- 【FPGA教程案例8】基于verilog的分频器设计与实现
- The crackdown on Huawei prompted made in China to join forces to fight back, and another enterprise announced to invest 100 billion in R & D
- Lottery system test report
- Mysql 45讲学习笔记(六)全局锁
- 同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
- Tar source code analysis 8
- what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
- Cell reports: Wei Fuwen group of the Institute of zoology, Chinese Academy of Sciences analyzes the function of seasonal changes in the intestinal flora of giant pandas
- [FPGA tutorial case 7] design and implementation of counter based on Verilog
- 期末周,我裂开
猜你喜欢
List of top ten professional skills required for data science work
期末周,我裂开
win10微软拼音输入法输入文字时候下方不出现中文提示
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
The final week, I split
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
移动适配:vw/vh
电脑通过Putty远程连接树莓派
Mobile adaptation: vw/vh
随机推荐
selenium驱动IE常见问题解决Message: Currently focused window has been closed.
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
[FPGA tutorial case 7] design and implementation of counter based on Verilog
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
com. alibaba. nacos. api. exception. NacosException
What is industrial computer encryption and how to do it
Tar source code analysis 9
Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
Tar source code analysis Part 7
The number of patent applications in China has again surpassed that of the United States and Japan, ranking first in the world for 11 consecutive years
tars源码分析之10
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
How can the old version of commonly used SQL be migrated to the new version?
tars源码分析之8
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
【FPGA教程案例8】基于verilog的分频器设计与实现
Data double write consistency between redis and MySQL
Download address of the official website of national economic industry classification gb/t 4754-2017
Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
tars源码分析之5