|
|
back to boardWhy WA #4? var sh,de:string; a:array[1..100]of integer; i,n:Integer; begin readln(sh); n:=length(sh); for i:=1 to n do a[i]:=ord(sh[i])-97; for i:=2 to n do if a[i]<a[i-1] then a[i]:=a[i]+((a[i-1]-a[i])div 26 + 1)*26; for i:=n downto 2 do a[i]:=a[i]-a[i-1]; a[1]:=a[1]-5; de:=''; for i:=1 to n do de:=de+chr(97+a[i] mod 26); writeln(de); end. i didn't understand where is my mistake Re: Why WA #4? a[1] can be less than 5. Re: Why WA #4? Edited by author 05.08.2011 16:43 Edited by author 05.08.2011 16:43 Re: Why WA #4? if you problem input is "adham" . what is output? output is "vdetm" . You should know if the first letter is "a" or "b" or "c" or "d" or "f" (char)("a" + 26) is correct way! Re: Why WA #4? Posted by BillSu 27 Apr 2014 18:03 You are great! I got the same mistake. |
|
|