From b689ef911f0ecff344b75f38bcf170408e8bb07c Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 20 Sep 2020 17:26:56 +0800 Subject: [PATCH] =?UTF-8?q?P1598=20=E5=9E=82=E7=9B=B4=E6=9F=B1=E7=8A=B6?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R38666209 --- problem/P1598/P1598.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 problem/P1598/P1598.cpp diff --git a/problem/P1598/P1598.cpp b/problem/P1598/P1598.cpp new file mode 100644 index 00000000..6906d7a9 --- /dev/null +++ b/problem/P1598/P1598.cpp @@ -0,0 +1,41 @@ +// R38666209 + +#include + +using namespace std; + +int main() { + char c; + int cnt[30]; + memset(cnt, 0x00, sizeof(cnt)); + while (cin >> c) { + cnt[c - 'A']++; + } + for (int i = 0; i <= 405; i++) { + int flag = 0, max = 0, end = 0; + for (int j = 0; j < 26; j++) { + if (cnt[j] >= max) { + max = cnt[j]; + end = j; + if (max != 0) { + flag = 1; + } + } + } + if (flag == 0) { + printf("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"); + break; + } + for (int j = 0; j <= end; j++) { + if (cnt[j] == max) { + printf("%s%c", j == 0 ? "" : " ", '*'); + cnt[j]--; + } + else { + printf("%s%s", j == 0 ? "" : " ", " "); + } + } + printf("\n"); + } + return 0; +}