计算分段函数[2]

浙大PTA C语言练习2-11 计算分段函数[2] 本题目要求计算下列分段函数f(x)的值: f2-11 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 #include <stdio.h> #include <math.h 阅读详情

本题目要求计算下列分段函数f(x)的值:

f2-11

注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。

输入格式:

输入在一行中给出实数x。

输出格式:

在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。

输入样例1:

10



结尾无空行

输出样例1:

f(10.00) = 3.16



结尾无空行

输入样例2:

-0.5

输出样例2:

f(-0.50) = -2.75

answer

#include <stdio.h>
#include <math.h>
int main() {
	double x;
	scanf("%lf",&x);
	if(x>=0){
		printf("f(%.2lf) = %.2lf",x,sqrt(x));
	}else{
		printf("f(%.2lf) = %.2lf",x,pow((x+1),2)+2*x+1/x);
	}
	return 0;
}
DEV C++ 计算分段函数[2] 编程练习 本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 代码: #include <stdio.h> #include <math.h> 阅读详情

相关推荐

练习2-10 计算分段函数【1】

练习2-10 计算分段函数[1](10 分) 本题目要求计算下列分段函数f(x)的值: 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留一位小数。 输入样例1: 10 输出样例1: f(10.0) = 0.1 输入样例2: 0 输出样例2: f(0.0) = 0.0 本题比...

melody_1016的博客 3万+

练习2-11 计算分段函数[2]

练习2-11 计算分段函数[2]

weixin_58280740的博客 2584

Qwen3.5本地部署实战:4B模型在RTX3060上离线运行指南

大语言模型本地化部署正从云端服务转向终端设备,其核心是模型轻量化、硬件适配与推理引擎协同优化。基于INT4量化感知训练和GGUF格式支持,Qwen3.5在结构精简、Tokenizer轻量及显存友好性方面显著优于前代,使4B级别模型可在RTX 3060等中端显卡上稳定运行。该技术路径兼顾低延迟响应(<2秒)、数据隐私保障与离线可用性,广泛适用于法律文书分析、医疗文档处理、教育AI助手等对安全性与实时性双重要求的场景。本文聚焦Qwen3.5-4B量化部署全流程,涵盖llama.cpp编译调优、GPU层加载策略及

weixin_32181267的博客 363

计算分段函数[2](C语言)

本题目要求计算下列分段函数f(x)的值:注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。

songyanZL的博客 943

Python爬虫实战:5分钟搞定东方财富网股票数据抓取(附完整代码)

本文详细介绍了如何使用Python爬虫快速抓取东方财富网的股票数据,包括环境配置、API分析、核心代码实现及优化技巧。通过简单的requests和pandas库,5分钟内即可获取高质量股票数据,适合量化交易和数据分析初学者。

weixin_29040367的博客 1182

MarkDown简介(深度解析MarkDown用法)

欢迎使用Markdown编辑器写博客 本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦: Markdown和扩展Markdown简洁的语法 代码块高亮 图片链接和图片上传 LaTex数学公式 UML序列图和流程图 离线写博客 导入导出Markdown文件 丰富的快捷键 快捷键 加粗 Ctrl + B 斜体 Ctrl + I...

酷酷的旭 7341

浙大版《C语言程序设计(第3版)》题目集 练习2-11 计算分段函数[2] (10 分)...

练习2-11计算分段函数[2](10 分) 本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f...

bangxiuop17915的博客 1561

LabVIEW vs Python:谁更适合你的ATE自动化测试系统?实测对比与选型建议

本文深入对比了LabVIEW和Python在ATE自动化测试系统中的性能表现、开发效率和应用场景,帮助工程师根据实时控制需求、数据处理复杂度及团队技能做出最优选型决策。通过实测数据和典型案例,分析两者在硬件集成、系统性能和维护成本等方面的差异,并提供混合架构实施建议。

weixin_29240711的博客 275

7-6 计算分段函数[2] (10 分)

本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 想法:规定了调用对应的函数记得加math.h #incl..

Ashes881502的博客 1115

UG二次开发避坑指南:如何正确配置Python环境让NXOpen脚本跑起来?

本文详细介绍了UG/NX二次开发中Python环境配置的全流程与NXOpen脚本调试技巧,帮助开发者避开常见陷阱。从NXOpen架构解析到Python解释器版本匹配,再到环境变量设置与路径问题处理,提供了一套经过验证的配置方案,确保脚本顺利运行。

weixin_33859135的博客 447

第一部分:VTK基础入门(第1章:VTK简介与概述)

VTK简介与核心特性概述 VTK(Visualization Toolkit)是一个开源的跨平台C++类库,专用于3D计算机图形学、图像处理和科学可视化。由Kitware公司开发,VTK自1993年起源以来,经历了开源化、成熟化和现代化多个发展阶段,现已成为科学可视化的核心工具之一。 VTK的核心特性包括: 管道架构:模块化设计实现数据流管理 丰富的数据支持:处理多边形数据、图像数据等 强大的渲染能力:集成OpenGL,支持多种渲染技术 最新版本VTK 9.4.2增强了现代C++支持,优化了内存管理,并提升

仰望星空的博客 2356

c语言 计算分段函数[2]

计算分段函数[2] 本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 #include <stdio.h> #include <math.

peoig的博客 3万+

lammps案例:扭转

扭转有两种方式,一是固定一端旋转另外一端,二是两端沿相反的方向旋转。案例为两侧旋转方式,扭转后的效果如图所示。

lammps_jiayou的博客 1199

[PTA] 计算分段函数[2]

本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 代码: #include<stdio.h> #

蓝胖子 (*^_^*)的博客 1万+

【Bug已解决】Claude Team Plan 购买席位报错 Payment failed 解决方案

方案适用场景推荐指数检查账单历史状态排查的第一步⭐⭐⭐⭐⭐更换支付方式类型快速尝试是否能绕开问题⭐⭐⭐联系官方支持团队最终解决问题的正规渠道⭐⭐⭐⭐⭐临时过渡方案紧急用人需求的应急处理⭐⭐⭐关注官方修复进度确认属于系统性缺陷的场景⭐⭐⭐⭐Claude Team Plan 增购席位报的问题,社区反馈和实际排查表明很大概率属于平台计费系统在处理按比例分摊费用这类复杂计算链路时的系统性缺陷,而不是用户自身的支付信息填写有误。先排除自身账单历史是否存在异常。

一键难忘的博客 4177

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

PTA7-4 计算分段函数[2] (10分)

PTA7-4 计算分段函数[2] (10分) #include<stdio.h> #include<math.h>//调用数学函数库 int main() { double x; double pow(double x,double y);//pow函数求幂 scanf("%lf",&x); if(x>=0) { printf("f(%.2lf) = %.2lf",x,pow(x,0.5)); } else{ printf("f(%.2lf) =

sdhuangzheng的博客 3883

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

pta练习2-11 计算分段函数[2]

练习2-11 计算分段函数[2] 本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 代码 #include<stdio.

Mambahr的博客 1124

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

7-88 计算分段函数[2]

本题目要求计算下列分段函数f(x)的值:注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。

m0_50039992的博客 154

7-6 计算分段函数[2]

本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 #include<stdio.h> #in.

玖月的博客 915

PTA平台之计算分段函数[2]

本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 输入样例2: -0.5 输出样例2: f(-0.50) = -2.75 废话不多说,直接上代码: x=float(input())

weixin_57728187的博客 941

7-10 计算分段函数[2] (10分)

本题目要求计算下列分段函数f(x)的值: 注:可在头文件中包含math.h,并调用sqrt函数求平方根,调用pow函数求幂。 输入格式: 输入在一行中给出实数x。 输出格式: 在一行中按“f(x) = result”的格式输出,其中x与result都保留两位小数。 输入样例1: 10 输出样例1: f(10.00) = 3.16 #include<stdio.h> #include<math.h> int main (void) { double x, result;

weixin_45814538的博客 3040
上一篇: 稳赢!!!
下一篇: 阶梯电价!
Sancean
博客等级 码龄6年 2472粉丝 149原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值