バージュンC++113パリンドロンを作る
5441 ワード
制作1213号パリンドロン
問題を解く
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int alpha[97];
string hol, zzac;
int main()
{
string s;
cin >> s;
for (char i : s)
{
alpha[i]++;
}
for (char i = 'A'; i <= 'Z'; i++)
{
if (alpha[i] % 2)
{
hol += i;
}
for (int j = 0; j < alpha[i] / 2; j++)
{
zzac += i;
}
}
if (hol.size() > 1)
{
printf("I'm Sorry Hansoo");
}
else
{
cout << zzac;
cout << hol;
reverse(zzac.begin(), zzac.end());
cout << zzac;
}
}
string、charに対する理解度が低いため、適切な使い方がよくわかりません.その結果,従来の複雑な方法を必要とせずに簡単に実現した.天才が多いですね.Reference
この問題について(バージュンC++113パリンドロンを作る), 我々は、より多くの情報をここで見つけました https://velog.io/@jaranda/백준-C-1213-팰린드롬만들기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol