当前位置:网站首页>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
边栏推荐
- 【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
- CORS is not intended to protect API endpoints - nikofischer
- Selection (021) - what is the output of the following code?
- 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
- How notepad++ counts words
- 【FPGA教程案例7】基于verilog的计数器设计与实现
- Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
- How to share the source code anti disclosure scheme
- MySQL 45 lecture learning notes (VII) line lock
- tars源码分析之6
猜你喜欢
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
[MySQL transaction]
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
Introduction to spark core components
Crawler (III) crawling house prices in Tianjin
The final week, I split
NLP literature reading summary
电脑通过Putty远程连接树莓派
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
随机推荐
Design of test cases
MySQL storage engine
NLP-文献阅读总结
Tar source code analysis Part 10
List of top ten professional skills required for data science work
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
Boast about Devops
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Selenium driver ie common problem solving message: currently focused window has been closed
【FPGA教程案例8】基于verilog的分频器设计与实现
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
[thread pool]
【森城市】GIS数据漫谈(一)
电脑通过Putty远程连接树莓派
【FPGA教程案例7】基于verilog的计数器设计与实现
Knowledge payment applet dream vending machine V2
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?
移动适配:vw/vh
校园网络问题
Mysql 45讲学习笔记(七)行锁