AOJ 0088 The Code A Doctor Loved
こんにちは川です。
今回はただただ作業でした。
対応している数字を入れて2進数計算させられただけ。
疲れた。
#include<bits/stdc++.h>
using
namespace
std;
int
main()
{
string str;
string first=
" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ"
,secound=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"
;
string conversion[32]={
"101"
,
"000000"
,
"000011"
,
"10010001"
,
"010001"
,
"000001"
,
"100101"
,
"10011010"
,
"0101"
,
"0001"
,
"110"
,
"01001"
,
"10011011"
,
"010000"
,
"0111"
,
"10011000"
,
"0110"
,
"00100"
,
"10011001"
,
"10011110"
,
"00101"
,
"111"
,
"10011111"
,
"1000"
,
"00110"
,
"00111"
,
"10011100"
,
"10011101"
,
"000010"
,
"10010010"
,
"10010011"
,
"10010000"
};
while
(getline(cin,str)){
string Midstream;
for
(
int
i=0;str[i]!=
'\0'
;i++){
for
(
int
j=0;j<33;j++)
if
(str[i]==first[j])Midstream+=conversion[j];
}
for
(
int
i=0;i<Midstream.size()%5;i++)Midstream+=
'0'
;
for
(
int
i=0,point=0;Midstream[i]!=
'\0'
;i++){
if
(i%5==4){
int
num=0;
for
(
int
j=point,kawa[5]={1,2,4,8,16};j<=i;j++)
num+=(Midstream[j]-
'0'
)*kawa[i-j];
cout<<secound[num];
point=i+1;
}
}
cout<<endl;
}
}