当前位置:网站首页>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
边栏推荐
- Selection (021) - what is the output of the following code?
- 抽奖系统测试报告
- Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
- Pangu open source: multi support and promotion, the wave of chip industry
- Splicing plain text into JSON strings - easy language method
- Mysql 45讲学习笔记(十四)count(*)
- uniapp小程序分包
- Deep profile data leakage prevention scheme
- How to input single quotation marks and double quotation marks in latex?
- 响应式移动Web测试题
猜你喜欢
leetcode825. Age appropriate friends
"Sword finger offer" 2nd Edition - force button brush question
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
Four sets of APIs for queues
Data double write consistency between redis and MySQL
win10微软拼音输入法输入文字时候下方不出现中文提示
校园网络问题
Centos8 install mysql 7 unable to start up
期末周,我裂开
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph
随机推荐
Latex中的单引号,双引号如何输入?
List of top ten professional skills required for data science work
Responsive - media query
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
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
2022年,或許是未來10年經濟最好的一年,2022年你畢業了嗎?畢業後是怎麼計劃的?
tars源码分析之8
移动适配: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
Mysql 45讲学习笔记(十)force index
How can the old version of commonly used SQL be migrated to the new version?
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
How to share the source code anti disclosure scheme
Chapter 1 programming problems
【森城市】GIS数据漫谈(一)
Tar source code analysis Part 10
电子协会 C语言 1级 35 、银行利息
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
Solution of running crash caused by node error