题目链接

https://www.patest.cn/contests/gplt/L1-023

AC代码

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <deque>
  6. #include <vector>
  7. #include <queue>
  8. #include <string>
  9. #include <cstring>
  10. #include <map>
  11. #include <stack>
  12. #include <set>
  13. #include <cstdlib>
  14. #include <ctype.h>
  15. #include <numeric>
  16. #include <sstream>
  17. using namespace std;
  18. typedef long long LL;
  19. const double PI = 3.14159265358979323846264338327;
  20. const double E = 2.718281828459;
  21. const double eps = 1e-6;
  22. const int MAXN = 0x3f3f3f3f;
  23. const int MINN = 0xc0c0c0c0;
  24. const int maxn = 1e5 + 5;
  25. const int MOD = 1e9 + 7;
  26. int main()
  27. {
  28. string s;
  29. cin >> s;
  30. int len = s.size();
  31. int i;
  32. int a[4] = {0};
  33. for (i = 0; i < len; i++)
  34. {
  35. if (s[i] == 'G' || s[i] == 'g')
  36. a[0]++;
  37. else if (s[i] == 'P' || s[i] == 'p')
  38. a[1]++;
  39. else if (s[i] == 'L' || s[i] == 'l')
  40. a[2]++;
  41. else if (s[i] == 'T' || s[i] == 't')
  42. a[3]++;
  43. }
  44. while (a[0] || a[1] || a[2] || a[3])
  45. {
  46. if (a[0])
  47. {
  48. printf("G");
  49. a[0]--;
  50. }
  51. if (a[1])
  52. {
  53. printf("P");
  54. a[1]--;
  55. }
  56. if (a[2])
  57. {
  58. printf("L");
  59. a[2]--;
  60. }
  61. if (a[3])
  62. {
  63. printf("T");
  64. a[3]--;
  65. }
  66. }
  67. cout << endl;
  68. }

PAT 天梯赛 L1-023. 输出GPLT 【水】的更多相关文章

  1. PAT 天梯赛 L1-026. I Love GPLT 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-026 AC代码 #include <iostream> #include <cstdio&g ...

  2. PAT 天梯赛 L2-021. 点赞狂魔 【水】

    题目链接 https://www.patest.cn/contests/gplt/L2-021 题意 给出一个若干个人名,后面给出点赞的总数,以及每个赞的标签类型,输出前三个点赞狂魔,按标签类型不同数 ...

  3. PAT 天梯赛 L1-047. 装睡 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-047 AC代码 #include <iostream> #include <cstdio&g ...

  4. PAT 天梯赛 L1-042. 日期格式化 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-042 AC代码 #include <iostream> #include <cstdio&g ...

  5. PAT 天梯赛 L1-041. 寻找250 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-041 AC代码 #include <iostream> #include <cstdio&g ...

  6. PAT 天梯赛 L1-022. 奇偶分家 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-022 AC代码 #include <iostream> #include <cstdio&g ...

  7. PAT 天梯赛 L1-016. 查验身份证 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-016 AC代码 #include <iostream> #include <cstdio&g ...

  8. PAT 天梯赛 L1-014. 简单题 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-014 AC代码 #include <iostream> #include <cstdio&g ...

  9. PAT 天梯赛 L1-012. 计算指数 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-012 AC代码 #include <iostream> #include <cstdio&g ...

  10. PAT 天梯赛 L1-010. 比较大小 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-010 AC代码 #include <iostream> #include <cstdio&g ...

随机推荐

  1. python学习代码

    #!/bin/python #example 1.1 #applay def function(a,b): print(a,b) def example1(): apply(function, (&q ...

  2. c++标准库之容器

    C++最原始的容器之一是数组.数组的特点有: 1.大小固定 2.单独存在的数组建立在栈上,作为对象成员存在的数组建立在堆上还是栈上则要看作为宿主对象是被建立在堆上还是栈上.栈空间是有限的,所以如果数组 ...

  3. Python urllib的urlretrieve()函数解析 (显示下载进度)

    #!/usr/bin/python #encoding:utf-8 import urllib import os def Schedule(a,b,c): ''''' a:已经下载的数据块 b:数据 ...

  4. Unity官方发布热更新方案性能对照

    孙广东  2016.3.11 Unity应用的iOS热更新 作者:丁治宇 Unity TechnologiesChina Agenda •  什么是热更新 •  为何要热更新 •  怎样在iOS 上对 ...

  5. Asp.net 基于Cookie简易的权限判断

    基于Cookie简易的权限判断代码,需要的朋友可以参考下. 写入Cookie页面,创建cookie后,设置cookie属性,并添加到Response.Cookies中读取cookie,利用cookie ...

  6. python3----连接字符串数组(join)

    join 方法用于连接字符串数组 s = ['a', 'b', 'c', 'd'] print(''.join(s)) print('-'.join(s)) results: abcd a-b-c-d ...

  7. Yii 2 的安装 之 踩坑历程

    由于刚接触yii2 ,决定先装个试试:可是这一路安装差点整吐血,可能还是水平有限吧,  但还是想把这个过程分享出来,让遇到同样问题的同学有个小小的参考,好了言归正传!! <(~.~)> 下 ...

  8. M - Tempter of the Bone(DFS,奇偶剪枝)

    M - Tempter of the Bone Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  9. SharePoint服务器端对象模型 之 访问网站和列表数据(Part 2)

    (二)列表(SPList) 列表是SharePoint中最为重要的数据容器,我们一般保存在SharePoint中的所有数据,都是保存在列表中(文档库也是一种列表),因此列表对象在SharePoint的 ...

  10. onload事件,解决不能在head写代码

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta http-equiv="con ...