AOJ 0127 Pocket Pager Input
こんにちは川です。
今回は、文字と数字を対応付けて解いていっただけです。
#include <bits/stdc++.h>
using
namespace
std;
int
main() {
string str;
char
poke[6][6]={{
"abcde"
},{
"fghij"
},{
"klmno"
},
{
"pqrst"
},{
"uvwxy"
},{
"z.?! "
}};
while
(cin>>str){
if
(str.size()%2!=0)cout<<
"NA"
<<endl;
else
{
string ans;
bool
kawa=0;
for
(
int
i=1;i<str.size();i+=2){
if
(str[i-1]-
'1'
<0||str[i-1]-
'1'
>5||
str[i]-
'1'
<0||str[i]-
'1'
>4){
kawa=1;
break
;
}
else
ans+=poke[str[i-1]-
'1'
][str[i]-
'1'
];
}
if
(kawa)cout<<
"NA"
<<endl;
else
cout<<ans<<endl;
}
}
return
0;
}