第三个点运行时错误,第四个点WA了

P1603 斯诺登的密码

lujiaju @ 2015-10-31 17:45:18

var
  s:array[1..1000] of string;
  a,word:ansistring;
  i,j,n:longint;
begin
  readln(a);
  word:=''; j:=0;
  if a[length(a)]='.' then delete(a,length(a),1);
  a:=a+' ';
  for i:=1 to length(a) do
    if a[i]=' ' then
    begin
      if (word='one')or(word='a')or(word='another')or(word='first') then begin inc(j); s[j]:='01'; end;
      if (word='two')or(word='second')or(word='both') then begin inc(j); s[j]:='04'; end;
      if (word='three')or(word='third') then begin inc(j); s[j]:='09'; end;
      if word='four' then begin inc(j); s[j]:='16'; end;
      if word='five' then begin inc(j); s[j]:='25'; end;
      if word='six' then begin inc(j); s[j]:='36'; end;
      if word='seven' then begin inc(j); s[j]:='49'; end;
      if word='eight' then begin inc(j); s[j]:='64'; end;
      if word='nine' then begin inc(j); s[j]:='81'; end;
      if word='ten' then begin inc(j); s[j]:='00'; end;
      if word='eleven' then begin inc(j); s[j]:='21'; end;
      if word='twelve' then begin inc(j); s[j]:='44'; end;
      if word='thirteen' then begin inc(j); s[j]:='69'; end;
      if word='fourteen' then begin inc(j); s[j]:='96'; end;
      if word='fifteen' then begin inc(j); s[j]:='25'; end;
      if word='sixteen' then begin inc(j); s[j]:='56'; end;
      if word='seventeen' then begin inc(j); s[j]:='89'; end;
      if word='eighteen' then begin inc(j); s[j]:='24'; end;
      if word='nineteen' then begin inc(j); s[j]:='61'; end;
      if word='twenty' then begin inc(j); s[j]:='00' end;
      word:='';
    end
    else word:=word+a[i];
  n:=j;
  for i:=1 to n do
    for j:=1 to n-i do
      if s[i]+s[j]<s[j]+s[i] then
      begin
        word:=s[i]; s[i]:=s[j]; s[j]:=word;
      end;
  a:='';
  for i:=1 to n do a:=a+s[i];
  while a[1]='0' do delete(a,1,1);
  if a='' then write(0)
  else writeln(a);
end.

by lujiaju @ 2015-10-31 17:45:56

我知道我打得很恶心。。。


by Philchieh @ 2016-02-10 16:36:32

知道就好


by CrTsIr400 @ 2020-06-26 21:22:41

考古


|