当前位置:网站首页>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
边栏推荐
- Responsive - media query
- Deep profile data leakage prevention scheme
- Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
- the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
- 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
- Crawler (III) crawling house prices in Tianjin
- Label management of kubernetes cluster
- Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
- Centos8 install mysql 7 unable to start up
- Mysql 45讲学习笔记(十二)MySQL会“抖”一下
猜你喜欢
关于IDEA如何设置快捷键集
How notepad++ counts words
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
期末周,我裂开
[MySQL transaction]
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
Vulhub vulnerability recurrence 76_ XXL-JOB
响应式——媒体查询
Campus network problems
Google Chrome Portable Google Chrome browser portable version official website download method
随机推荐
Data double write consistency between redis and MySQL
win10微软拼音输入法输入文字时候下方不出现中文提示
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph
2022, peut - être la meilleure année économique de la prochaine décennie, avez - vous obtenu votre diplôme en 2022? Comment est - ce prévu après la remise des diplômes?
Tar source code analysis Part 7
Pangu open source: multi support and promotion, the wave of chip industry
电子协会 C语言 1级 34 、分段函数
Check and display one column in the known table column
MySQL 45 lecture learning notes (VII) line lock
移动适配:vw/vh
Boast about Devops
MySQL storage engine
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Download address of the official website of national economic industry classification gb/t 4754-2017
Vulhub vulnerability recurrence 77_ zabbix
Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
高薪程序员&面试题精讲系列119之Redis如何实现分布式锁?
How notepad++ counts words
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
Boast about Devops