L1-023 输出GPLT (20 分)

C语言程序练习-L1-023 输出GPLT (20分) L1-023 输出GPLT (20分) 给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT…这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。 输出格式: 在一行中按题目要求输出排序后的字符串。题目保证输出非空。 输入样例: pcTclnGloRgLrtLh 阅读详情

L1-023 输出GPLT (20 分)

给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT....这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。

输入格式:

输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。

输出格式:

在一行中按题目要求输出排序后的字符串。题目保证输出非空。

输入样例:

pcTclnGloRgLrtLhgljkLhGFauPewSKgt

输出样例:

GPLTGPLTGLTGLGLL

作者: 陈越

单位: 浙江大学

时间限制: 150 ms

内存限制: 64 MB

代码长度限制: 16 KB


编译器:C++(g++)

#include<bits/stdc++.h>
using namespace std;
char a[10005];
int main(){
	int g=0,p=0,l=0,t=0;
	scanf("%s",&a);
	for(int i=0;i<=strlen(a);i++){
		if(a[i]=='g'||a[i]=='G') g++;
		if(a[i]=='p'||a[i]=='P') p++;
		if(a[i]=='l'||a[i]=='L') l++;
		if(a[i]=='t'||a[i]=='T') t++;
	}
	while(g+p+l+t>0){
		if(g>0){
			cout<<"G";
			g--;
		}
		if(p>0){
			cout<<"P";
			p--;
		}
		if(l>0){
			cout<<"L";
			l--;
		}
		if(t>0){
			cout<<"T";
			t--;
		}

	}
	return 0;
} 

 

PTA L1-023 输出GPLT(20分) C语言实现 L1-023 输出GPLT分数 20全屏浏览题目切换布局作者 陈越单位 浙江大学给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 阅读详情

相关推荐

L1-023 输出GPLT (20分)(C语言)

L1-023 输出GPLT (20分)(C语言) 给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT…这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。 输出格式: 在一行中按题目要求输出排序后的字符串。题目保证输出非空。 输入样例: pcTclnGloRgL

qq_39915248的博客 751

PTA 乙级1043 输出PATest (20 分)

1043 输出PATest (20 分) 给定一个长度不超过 10 ​4 ​​ 的、仅由英文字母构成的字符串。请将字符重新调整顺序,按 PATestPATest… 这样的顺序输出,并忽略其它字符。当然,六种字符的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按 PATest 的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过 10^​4的、仅由英文字母构成...

一蓑烟雨任平生 587

西工大noj100题python2024第三季21-30

【代码】西工大noj100题python2024第三季21-30。

weixin_70523540的博客 1576

L1-023 输出GPLT (20分)

给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT…这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。 输出格式: 在一行中按题目要求输出排序后的字符串。题目保证输出非空。 输入样例: pcTclnGloRgLrtLhgljkLhGFauPewSKgt 输出

陈同学的博客 1059

Unity ProBuilder(自己创建斜面、拐角)

ProBuilder基础实例

weixin_56537692的博客 1551

硬件之光实战篇--Boost

当开关管处于关闭状态时,由于电感中的电流在短时间内不能瞬间消失,因此它会产生一个电感电动势,在电容器上加上一个高电压,从而使输出电压变高。--------------------------------------------------------分割线----------------------------------------------------------------在应用中,升压芯片需要根据负载电路的需求,选择合适的电感和电容等元器件,以达到所需要的升压倍数和输出电压。

m0_58664890的博客 2100

天梯赛022输出GPTL

给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT…这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。 输出格式: 在一行中按题目要求输出排序后的字符串。题目保证输出非空。 输入样例: pcTclnGloRgLrtLhgljkLhGFauPewSKgt 输出样

alongwaywith的博客 803

EBS开发_创建AP付款

--以下代码于20181002在Tony环境测试通过 /* BEGIN   --mo_global.init('SQLAP');   apps.fnd_global.apps_initialize(user_id =&gt; 1110, resp_id =&gt; 50597, resp_appl_id =&gt; 20003);   --mo_global.set_policy_context(...

蜗牛先生快跑的博客 4766

L1-023 输出 GPLT - 20分

摘要:本文解析天梯赛L1-023输出GPLT题目,要求筛选字符串中的G/P/L/T字符(不区分大小写),并按固定顺序循环输出。提供C和C++两种解法:C语言使用字符数组和数组计数,C++采用string容器和独立变量计数。核心思路是遍历统计字符数量后,通过轮询检查实现顺序输出。两种方法时间复杂度均为O(n),C++代码更简洁。文章强调不区分大小写的处理、循环输出逻辑等考点,并比较两种语言的实现差异,适合初学者理解基础字符串处理技巧。(149字)

2603_95058369的博客 823

【YOLOv8系列】在Windows上离线搭建YOLOv8运行环境

我们都知道,通过 pip安装YOLOv8是非常方便的,但是有时候网络环境受到限制,比如公司的工作站(无法连接网络)或者机房的教学机器等等,只能通过离线的方式安装YOLOv8;今天就来记录一下离线搭建YOLOv8运行环境的过程。并记录了遇到的问题及解决过程。

AnChenliang_1002的博客 2004

串口、COM、UART、TTL、USB、RS-232、RS-485、I2C、SPI、CAN、1-WIRE

一文搞定,赶紧收藏吧

记得诚 3万+

PTA L1-023 输出GPLT (20 分)

如花美眷,似水流年,回得了过去,回不了当初。 给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT....这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的...

0k-ok 837

【Python爬虫教程】第3篇-解决使用reqeusts遇到的ProxyError异常

Python request代理错误提示“HTTPSConnectionPool, Cannot connect to proxy, no such file or directory”

分享技术,记录思考和感悟 1507

PTA-团体程序设计天梯赛 L1-023 输出GPLT(20分)

PTA-团体程序设计天梯赛 L1-023 输出GPLT

m0_54750154的博客 647

【VTKExamples】PolyData-1:: CellEdgeNeighbors & CellPointNeighbors 检索Cell边相邻的Cells & 检索Cell点相邻的Cells

本文主要分享VTKExample中两个样例CellEdgeNeighbors.cxx & CellPointNeighbors.cxx,了解VTK中如何对Cell进行邻域检索!输入模型 基于Edge检索结果 基于Point检索结果目录前言1. 基于Edge检索核心代码2.基于Point检索核心代码3.基于Edge检索样例代码4. 基于Point检索样例代码1.

qq_40041064的博客 672

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

[Python] L1-023 输出GPLT (20分)

L1-023输出GPLT(20分) 给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT....这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字...

chen_zan_yu_的博客 542

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

L1-023 输出GPLT (20 分)

给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT....这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。 输出格式: 在一行中按题目要求输出排序...

qq_45798109的博客 140

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

L1-023 输出GPLT (20 分)

L1-023 输出GPLT (20 分) 给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT....这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空...

Mercury_Lc的博客 380

C++实现 L1-023 输出GPLT (20分)

C++实现 L1-023 输出GPLT (20分) 一、描述 给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT...GPLTGPLT...GPLTGPLT...这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 二、输入格式 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。 三、输出格式 在一行中按题目要求输出排序后的

pioneer水的博客 1138

L1-023 输出GPLT (20分)|简短

L1-023 输出GPLT (20分) 输入样例: pcTclnGloRgLrtLhgljkLhGFauPewSKgt 输出样例: GPLTGPLTGLTGLGLL 代码如下: #include<iostream> #include<algorithm> #include<string> using namespace std; int main() {...

diviner_s的博客 471

天梯L1-023 输出GPLT (20分)

给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按GPLTGPLT…这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。 输入格式: 输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。 输出格式: 在一行中按题目要求输出排序后的...

a180a的博客 195
上一篇: L1-022 奇偶分家 (10 分)
下一篇: L1-024 后天 (5 分)
黑色吊椅
博客等级 码龄9年 102粉丝 78原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值