PAT 团体程序设计天梯赛-练习集 L1-023. 输出GPLT
2024-08-24 10:00:13
给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按“GPLTGPLT....”这样的顺序输出,并忽略其它字符。当然,四种字符(不区分大小写)的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按GPLT的顺序打印,直到所有字符都被输出。
输入格式:
输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。
输出格式:
在一行中按题目要求输出排序后的字符串。题目保证输出非空。
输入样例:
pcTclnGloRgLrtLhgljkLhGFauPewSKgt
输出样例:
GPLTGPLTGLTGLGLL
#include<stdio.h>
#include<iostream>
#include<cstring>
using namespace std;
char GPLT[]={'G','P','L','T'};
int main()
{
char s[];
int gplt[];
for(int i=;i<;i++)
gplt[i]=;
cin>>s;
int len=strlen(s);
for(int i=;i<len;i++)
{
if(s[i]=='G'||s[i]=='g')
gplt[]++;
else if(s[i]=='P'||s[i]=='p')
gplt[]++;
else if(s[i]=='L'||s[i]=='l')
gplt[]++;
else if(s[i]=='T'||s[i]=='t')
gplt[]++;
}
int sum=gplt[]+gplt[]+gplt[]+gplt[];
while(sum--)
{
for(int i=;i<;i++)
if(gplt[i]!=)
{
printf("%c",GPLT[i]);
gplt[i]--;
}
}
printf("\n");
return ;
}
最新文章
- 【C#公共帮助类】给大家分享一些加密算法 (DES、HashCode、RSA、AES等)
- [转]spring beans.xml
- update the UI property cross thread
- 编辑器插件数据保存之Serializable
- Linux下的mongodb分片部署
- 安装 SQL SERVER PROFILER
- work_5
- (转载)四种常见的 POST 提交数据方式
- 转--Oracle DB 服务器系统时间修改问题与 SCN 关系的深入研究
- F题 - A+B for Input-Output Practice (V)
- Android开发知识体系总结
- Linux运维:安装CentOS7.2-图解
- mysql-innoDB-锁
- 元素化设计原理及规则v1.0
- 18 UI美化自定义主题样式代码
- PLC 数据类型
- js项目练习第二课
- Linux:Day8(上) 文件系统挂载和管理工具
- c# 数据存储过程
- CTFcrackTools-V3 - 一款旨在帮助 CTFer 在 CTF 中发挥作用的一个框架
热门文章
- js的eval函数解析后台返回的json数据时为什加上圆括号eval(";(";+data+";)";),而HTML页面定义的数据不用
- CrashMe分析教程1 - BreakPoint
- TypeScript 学习二 表达式和循环
- Linux下的数据监控工具
- react-router的基础知识
- intellij 出现“Usage of API documented as @since 1.6+”的解决办法
- layer ifram 弹出框
- magento获取一些值的方法函数
- Web Service接口返回泛型的问题(System.InvalidCastException: 无法将类型为“System.Collections.Generic.List`1[System.String]”的对象强制转换为类型“System.String[]”)
- 【Python】协程实现生产者消费者模型