当前位置:网站首页>L1-023 output gplt (20 points)
L1-023 output gplt (20 points)
2022-07-04 07:29:00 【Inter personal liabilities^】
L1-023 Output GPLT (20 branch )
A given length does not exceed 10000 Of 、 A string consisting only of English letters . Please reorder the characters , Press GPLTGPLT....
Output in this order , And ignore the other characters . Of course , Four types of characters ( Case insensitive ) It doesn't have to be the same number , If a character has been printed out , Then press the remaining characters GPLT
Sequential printing , Until all characters are printed .
Input format :
The input is given in a line with a length not exceeding 10000 Of 、 A non - empty string consisting only of English letters .
Output format :
Output the sorted string on a line by the title . The question guarantees that the output is not empty .
sample input :
pcTclnGloRgLrtLhgljkLhGFauPewSKgt
sample output :
GPLTGPLTGLTGLGLL
First, convert all the characters in the string into uppercase letters , Then count the number of corresponding letters , Just keep outputting
tolower() The function converts all strings into lowercase letters
toupper() The function converts all strings into uppercase letters
AC Code
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;
const int N=100010;
int main()
{
int G = 0, P = 0, L = 0, T = 0;
string a;
cin >> a;
int len = a.size();
for(int i = 0; i < len; i ++ )
{
if(toupper(a[i]) == 'G') G ++ ;
else if(toupper(a[i]) == 'P') P ++ ;
else if(toupper(a[i]) == 'L') L ++ ;
else if(toupper(a[i]) == 'T') T ++ ;
}
while(G || P || L || T)
{
if(G)
{
cout << 'G';
G -- ;
}
if(P)
{
cout << 'P';
P -- ;
}
if(L)
{
cout << 'L';
L -- ;
}
if(T)
{
cout << 'T';
T -- ;
}
}
return 0;
}
边栏推荐
- com. alibaba. nacos. api. exception. NacosException
- Mysql database - function constraint multi table query transaction
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- 【Kubernetes系列】Kubernetes 上安装 KubeSphere
- I was pressed for the draft, so let's talk about how long links can be as efficient as short links in the development of mobile terminals
- Master-slave replication principle of MySQL database
- MYCAT middleware installation and use
- Vulhub vulnerability recurrence 76_ XXL-JOB
- 电子协会 C语言 1级 34 、分段函数
- Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
猜你喜欢
Solution of running crash caused by node error
用于压缩视频感知增强的多目标网络自适应时空融合
Distributed transaction management DTM: the little helper behind "buy buy buy"
What are the work contents of operation and maintenance engineers? Can you list it in detail?
MySQL storage engine
Experience installing VMware esxi 6.7 under VMware Workstation 16
Xcode 14之大变化详细介绍
MySQL中的文本处理函数整理,收藏速查
What is industrial computer encryption and how to do it
两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙
随机推荐
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
Guoguo took you to write a linked list, and the primary school students said it was good after reading it
【Kubernetes系列】Kubernetes 上安装 KubeSphere
Computer connects raspberry pie remotely through putty
Transition technology from IPv4 to IPv6
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
[Mori city] random talk on GIS data (I)
Text processing function sorting in mysql, quick search of collection
MySQL中的文本处理函数整理,收藏速查
用于压缩视频感知增强的多目标网络自适应时空融合
Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
Zephyr 学习笔记2,Scheduling
Advanced MySQL: Basics (5-8 Lectures)
Status of the thread
Unity 从Inspector界面打开资源管理器选择并记录文件路径
Set JTAG fuc invalid to normal IO port
Blog stop statement
[Valentine's day] - you can change your love and write down your lover's name
Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture