为什么80分

P1914 小书童——凯撒密码

784452232zcn30 @ 2015-10-11 20:42:52

var
  n,i:longint;
  s:string;
begin
  readln(n);
  readln(s);
  for i:=1 to n do
    begin
      if ord(s[i])+n>122 then s[i]:=chr(ord(s[i])+n-26)
        else s[i]:=chr(ord(s[i])+n);
    end;
  writeln(s);
end.

by ArnoD @ 2015-10-12 12:13:52

  readln(x);
  s:='abcdefghijklmnopqrstuvwxyz';
  s:=s+s;
  readln(n);
  for i:=1 to length(n) do
write(s[ord(n[i])-96]);

by qzwuhaoming @ 2015-11-01 13:47:25

var
  s:string;
  i,j,n:longint;
begin
  readln(n);
  readln(S);
  for i:=1 to length(s) do
    begin
      if ord(s[i])+n<ord('a')+26 then
        write(chr(ord(s[i])+n)) else
        write(chr((ord(s[i])+n-ord('a')) mod 26+ord('a')));
    end;
end.

by liaopifan @ 2016-05-29 17:57:47

检查一下char是不是溢出了(char能存的范围是-128~127)


|