pat 1009

pat乙级 1009 题解 零、错误原因 在接受本题中这种含有空格的字符串时选择了scanf而不是gets,导致读取到的字符串只是第一个空格前的单词 一、整体思路 读入输入的字符串后,依次找出字符串中的每一个单词并存储在对应数组中,最后再反向输出 二、关键问题 1.如何找出字符串中的每一个单词 2.如何实现各单词的分别存储 三、关键问题对应的解决方法 1.遍历输入的字符串,当遍历到空格符时该空格符的下一个字符即为下一单词的内容 2.使用二维数组存储各单词,二维数组的行数标志着各单词的顺序与对应地址,当遍历 阅读详情

多项式乘法:
用一个数组储存相乘后的到的元素
使用double型的数组,下标表示指数,対应的值表示系数。

#include<stdio.h>
#include<math.h>

typedef struct{
    int expon;
    double coef;
}poly;

poly a[15],b[15];
double ans[2008];
int k1,k2,cnt=0;

void Input()
{
    scanf("%d",&k1);
    for(int i=0;i<k1;i++)
    {
        scanf("%d %lf",&a[i].expon,&a[i].coef);
    }
    scanf("%d",&k2);
    for(int i=0;i<k2;i++)
    {
        scanf("%d %lf",&b[i].expon,&b[i].coef);
    }
}

int main()
{
    Input();
    for(int i=0;i<k1;i++){
        for(int j=0;j<k2;j++){
            ans[a[i].expon+b[j].expon] += a[i].coef*b[j].coef;
        }
    }

    for(int i=0;i<2005;i++){
        if(fabs(ans[i])>0)
            cnt++;
    }
    printf("%d",cnt);
    for(int i=2000;i>=0;i--){
        if(fabs(ans[i])>0){
            printf(" %d %.1lf",i,ans[i]);
        }
    }

    printf("\n");
    return 0;
}









PAT甲级1009 测试点0 PAT甲级 测试点坑点总结1009 Product of Polynomials 1009 Product of Polynomials 测试点0:系数项可能为负数,所以有些项的系数会为零,此时不应输出 #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; map<i... 阅读详情

相关推荐

AT32F435/437开发实战:把SD卡变成U盘的完整指南(含源码解析)

本文提供了基于AT32F435/437微控制器将SD卡改造为U盘的完整实战指南。通过深入解析USB MSC协议与SDIO驱动的协同工作原理,详细介绍了硬件设计要点、软件架构融合、核心源码解析以及从编译到文件传输的完整调试流程,帮助开发者实现可靠的大容量存储设备扩展。

weixin_29159127的博客 410

C语言PAT刷题 - 1009 说反话

并非大佬,仅仅分享自己在PAT刷题过程中的解题思路,希望能对遇到问题的朋友有所帮助。若有错漏,欢迎指正,也欢迎大家分享更好的方法。

扶酒劝斜阳的博客 1822

CentOS7 编译升级GCC至9.3.0

1)下载GCC9.2.0源码并解压 从GCC官方FTP下载地址可以看到GCC最新版本为9.3.0。由于官网下载速度慢,实际上用清华大学的镜像站进行下载,代码如下: wget -c /opt/tmp/ https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz #考虑到安装失败的可能性,创建一个临时文件夹来安装GCC...

haha123486的博客 1万+

PAT 1009 解析

PAT 1009 解析 C语言 + Visual C++ 6.0

weixin_45310635的博客 284

在ArcGIS Pro软件中进行滑坡的敏感性和易发性分析

滑坡的敏感性和易发性分析需要综合地形、水文、地质及环境等多维数据,本文罗列了基于ArcGIS Pro软件进行的一系列可执行分析。

weixin_49609713的博客 1732

#Linux内存管理# 用一个案例详细介绍ARMv7-A架构 缺页中断处理的原理

跳转到异常向量:根据 异常向量表基地址(通常配置在 VBAR 寄存器中,例如 0xFFFF0000) + 数据中止异常的偏移量 0x10,跳转到数据中止异常的处理程序入口点 0xFFFF0010(实践中,这个入口通常是一条跳转到更复杂处理函数的指令)。malloc 通常不会立即分配物理内存页,它只是在内核为该进程维护的虚拟地址空间中找到一段足够大的空闲虚拟地址区域(比如 0x00008000 - 0x00008FFF),标记为已用,并返回起始地址(例如 0x00008000)给程序。

sinat_37817094的博客 993

PAT乙级1009. 说反话(C语言)

PAT乙级真题题解目录 /* * 1. 输入含空格的字符串:用 gets() 读取 * 2. 句子颠倒,单词本身字母不颠倒: * 2.1 从末尾单词开始输出 * 2.2 利用指针使单词本身正序 * 2.3 空格是单词结束的标识 */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; ...

对方北方 4448

MobaXterm远程连接频繁掉线?3个SSH保活设置让你告别断连烦恼

本文针对MobaXterm远程连接频繁掉线问题,提供了3个SSH保活设置方案。从基础的SSH心跳机制到进阶的会话超时调整,再到TCP层保活与代理优化,全方位解决断连烦恼。特别适合需要稳定远程连接的开发者和运维人员,有效提升工作效率。

weixin_29250573的博客 486

PAT乙级真题—1009 说反话(C++)

PAT乙级真题—1009 说反话(C++)

m0_47679695的博客 392

SAP_FI模块_固定资产期初导入全流程(含导入代码)

SAP 期初导入资产主数据以及金额相关的操作全流程记录,包含了批导程序的代码,以及错误记录

风沙的博客 1405

Agent驱动电商运营:从选品到售后的全链路革新

在当今竞争激烈的电商市场中,传统的电商运营模式面临着诸多挑战。从选品到售后,每个环节都需要大量的人力投入和专业知识。选品需要深入了解市场趋势和消费者需求,营销需要精准定位目标用户,客服需要24小时响应用户咨询。这些工作不仅耗时耗力,而且容易受到人为因素的影响,导致效率低下和成本高企。AI Agent是一种能够感知环境、做出决策并采取行动的智能系统。感知能力:能够获取和处理环境信息。决策能力:能够根据感知到的信息做出决策。行动能力:能够执行决策,对环境产生影响。学习能力。

AI 领航者的博客 354

PAT甲级1009

1009Product of Polynomials(25point(s)) This time, you are supposed to findA×BwhereAandBare two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a po...

qq_40639828的博客 269

在 SAP 系统中,成本中心(Cost Center)是成本核算与费用管控的基础组织单元,其设计质量直接决定了后续成本归集、分摊、分析及责任考核的准确性

SAP系统成本中心设计核心要点:1. 设计原则包括责任可控、业务同质、核算颗粒度适配、组织对齐及稳定性平衡;2. 划分维度主要有部门、功能、地域、项目和资产5类,可组合使用;3. 需避免颗粒度过细、跨责任主体归集等常见误区;4. 建议采用"明确目标-梳理业务-设计编码"三步法,建立科学的成本中心体系。合理的成本中心设计能精准归集费用、明确责任主体,为成本分析和管控奠定基础。

金牌架构师 1439

PAT乙级1009

题目链接 https://pintia.cn/problem-sets/994805260223102976/problems/994805316250615808 题解一 我的方法如下: 将这一行字符串格式看做:第一个单词( 单词)( 单词)( 单词) 利用循环输出所有( 单词) 输出第一个单词 // PAT BasicLevel 1009 // https://pintia.cn...

weixin_30421525的博客 145

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

深度学习工具包 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")

PAT 1009 说反话

PAT 1009 说反话 题目: 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过 80 的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。 输出格式: 每个测试用例的输出占一行,输出倒序后的句子。 输入样例: Hello...

金鱼的博客 237

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

PAT 1009

PAT 1009 题目:给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过 80 的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。 输出格式: 每个测试用例的输出占一行,输出倒序后的句子。 输入样例: Hello World...

格格格子曼的博客 139

PAT B 1009

PAT B 1009 题目地址: https://www.patest.cn/contests/pat-b-practise/1009 题目描述: 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过80的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用1个空格分开,输入保...

铭泽的博客 227

PAT1009 说反话 c++

PAT1009 说反话 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过 80 的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。 输出格式: 每个测试用例的输出占一行,输出倒序后的句子。 输入样例: Hello Worl...

mystery1221的博客 378

PAT甲级 1009 - Product of Polynomials

PAT甲级 1009题目 Product of Polynomials解析代码 题目 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each input file contains one test c...

qq_37208650的博客 333

【PAT】1009 说反话

【PAT】1009 说反话 题目思路代码 题目 1009 说反话 (20分) 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过 80 的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。 输出格式: 每个测试用例的输出占一行,输出倒序后的句子。 输入样例: Hello World Here I Come 输出样例: Come I H

五百零一 98

PAT B1009

PAT Basic Level 1009 1009 说反话 (20 分) 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。 输入格式: 测试输入包含一个测试用例,在一行内给出总长度不超过 80 的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。 输出格式: 每个测试用例的输出占一行,输...

weixin_40530664的博客 187

PAT甲级 1009 Product of Polynomials

PAT甲级 1009 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, an...

旺崽的博客 2882

PAT Basic 1009

PAT Basic 1009 说反话 (20) 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。

M_Linx的博客 272
上一篇: Pat 1002
下一篇: 03-树2 List Leaves (25分)
M_cry
博客等级 码龄12年 7粉丝 56原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值