现在的位置: 首页 > 综合 > 正文

poj2608

2018年04月26日 ⁄ 综合 ⁄ 共 719字 ⁄ 字号 评论关闭

【题意】

给定一串长度不超过20的字符串,

BFPV表示为1

CGJKQSXZ表示为2

DT表示为3

L表示为4

MN表示为5

R表示为6

AEIOUHWY什么也不表示

如果这一位表示的跟前一位表示的相同,则不输出

【输入】

多组数据

每组一行,为字符串

【输出】

每组数据输出一个翻译过来的数字串

写个case就过了

program poj2608;
var
  s:string;
  i,j,k,last:longint;
function hash (now:char):longint;
begin
  case now of
    'B':exit(1);
    'F':exit(1);
    'P':exit(1);
    'V':exit(1);
    'C':exit(2);
    'G':exit(2);
    'J':exit(2);
    'K':exit(2);
    'Q':exit(2);
    'S':exit(2);
    'X':exit(2);
    'Z':exit(2);
    'D':exit(3);
    'T':exit(3);
    'L':exit(4);
    'M':exit(5);
    'N':exit(5);
    'R':exit(6);
    'A':exit(0);
    'E':exit(0);
    'I':exit(0);
    'O':exit(0);
    'U':exit(0);
    'H':exit(0);
    'W':exit(0);
    'Y':exit(0);
  end;
end;

begin
  while not eof do
    begin
      readln(s);
      last:=-1;
      for i:=1 to length(s) do
        begin
          if (hash(s[i])<>0)and(hash(s[i])<>last) then write(hash(s[i]));
          last:=hash(s[i]);
        end;
      writeln;
    end;
end.
【上篇】
【下篇】

抱歉!评论已关闭.