当前位置:网站首页>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
边栏推荐
- MySQL storage engine
- Lottery system test report
- 期末周,我裂开
- CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
- Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
- Splicing plain text into JSON strings - easy language method
- The difference between synchronized and lock
- 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
- How can the old version of commonly used SQL be migrated to the new version?
- 由于dms升级为了新版,我之前的sql在老版本的dms中,这种情况下,如何找回我之前的sql呢?
猜你喜欢

Deep profile data leakage prevention scheme

Wechat applet scroll view component scrollable view area

Mobile adaptation: vw/vh

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

notepad++如何统计单词数量
![[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph](/img/5e/7ce21dd544aacf23b4ceef1ec547fd.png)
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph

NLP-文献阅读总结

List of top ten professional skills required for data science work
![[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA](/img/71/1d6179921ae84b1ba61ed094e592ff.png)
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA

Set JTAG fuc invalid to normal IO port
随机推荐
tars源码分析之7
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
Design of test cases
Novel website program source code that can be automatically collected
《剑指Offer》第2版——力扣刷题
NLP literature reading summary
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源码分析之3
Analysis of tars source code 1
校园网络问题
Uniapp applet subcontracting
Analysis of tars source code 5
Boast about Devops
Mysql 45讲学习笔记(十二)MySQL会“抖”一下
Finishing (III) - Exercise 2
uniapp小程序分包
List of top ten professional skills required for data science work
JS common time processing functions
2022年6月小结
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA