当前位置:网站首页>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;
}
边栏推荐
- 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
- Directory of tornado
- Deep profile data leakage prevention scheme
- In the era of low code development, is it still needed?
- Zephyr learning notes 1, threads
- tornado项目之路由装饰器
- [real case] how to deal with the failure of message consumption?
- Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
- [Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)
- MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
猜你喜欢
Zephyr 学习笔记1,threads
SQL foundation 9 [grouping data]
Comparison between applet framework and platform compilation
电脑通过Putty远程连接树莓派
A real penetration test
Unity opens the explorer from the inspector interface, selects and records the file path
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
Industrial computer anti-virus
Text processing function sorting in mysql, quick search of collection
Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
随机推荐
Implementation of ZABBIX agent active mode
A real penetration test
2022-021ARTS:下半年開始
[Mori city] random talk on GIS data (I)
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
节点基础~节点操作
It's healthy to drink medicinal wine like this. Are you drinking it right
Would you like to go? Go! Don't hesitate if you like it
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
Status of the thread
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
rapidjson读写json文件
One of the general document service practice series
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
tornado项目之路由装饰器
Two years ago, the United States was reluctant to sell chips, but now there are mountains of chips begging China for help
[freertos] freertos Learning notes (7) - written freertos bidirectionnel Link LIST / source analysis
Jianmu continuous integration platform v2.2.2 release
[Flink] temporal semantics and watermark