46 条题解
-
0td650739 LV 8 @ 2013-08-15 16:15:24
虽然是水题但是我依然凌乱了~~不过反正过了就好。。。1A!o( ̄▽ ̄)o
Var r:array['A'..'Z','A'..'Z'] of char;
j:longint;
miyao,miwen:ansistring;
i,k:char;
Begin
For i:='A' to 'Z' do
Begin
j:=1;
While j<=26 do
Begin
r[i,chr(ord('A')+j-1)]:=chr(ord('A')+(ord(i)-ord('A')+j-1) mod 26);
inc(j);
End;
End;
readln(miyao);
readln(miwen);
While length(miyao)<length(miwen) do miyao:=miyao+miyao;
For j:=1 to length(miyao) do if (miyao[j]>='a') and (miyao[j]<='z') then miyao[j]:=upcase(miyao[j]);
For j:=1 to length(miwen) do
For i:='A' to 'Z' do
If (r[i,miyao[j]]=upcase(miwen[j])) then
If (miwen[j]>='a') and (miwen[j]<='z') then
write(lowercase(i)) else write(i);
readln;
End. -
02013-04-30 10:08:13@
送分的题
var
c,m:array[1..1000] of char;
k:array[1..100] of char;
cl,kl,i,j:integer;
begin
assign(input,'vigenere.in');
assign(output,'vigenere.out');
reset(input);
rewrite(output);
while not eof do
begin
cl:=0; kl:=0;
while not eoln do
begin
inc(kl);
read(k[kl]);
end;
readln;
while not eoln do
begin
inc(cl);
read(c[cl]);
end;
readln;
end;
j:=1;
for i:= 1 to cl do
begin
case c[i] of
'A'..'Z':m[i]:=chr((ord(c[i])-ord(upcase(k[j]))+26)mod 26 +65);
'a'..'z':m[i]:=chr((ord(c[i])-ord(lowercase(k[j]))+26)mod 26 +97);
end;
j:=j mod kl +1;
end;
for i:=1 to cl do
write(m[i]);
close(input);
close(output);
end. -
02013-02-23 17:35:52@
var s,k:ansistring;i,t:longint;
function get(var key,ch:char):char;
var j:char;
begin
if key in ['a'..'z'] then
key:=chr(ord(key)-32);
if key<>'A' then
for j:='B' to key do
case ch of
'a': ch:='z';
'A': ch:='Z' ;
else
ch:=pred(ch);
end;
exit(ch);
end;
begin
assign(input,'vigenere.in');
assign(output,'vigenere.out');
reset(input);
rewrite(output);
readln(k);
readln(s);
t:=length(k);
for i:=t+1 to 1000 do
if i mod t=0 then
insert(k[t],k,i)
else
insert(k[i mod t],k,i);
for i:=1 to length(s) do
write(get(k[i],s[i]));
close(output);
end. -
02012-11-25 13:25:08@
数据好弱,这样的程序居然没超时啊
program P1778;
var
m,n:ansistring;
x:char;
i,j,k,l,c:integer;
begin
readln(m);
readln(n);
for i:=1 to length(m) do
m[i]:=lowercase(m[i]);
c:=length(m);
for i:=1 to 10 do
m:=m+m;
for i:=1 to length(n) do
begin
case n[i] of
'A'..'Z':
for x:='A' to 'Z' do
begin
j:=ord(m[i])-65;
k:=ord(x)-97;
l:=(k+j) mod 26+65;
if chr(l)=n[i] then begin write(x); break; end;
end;
'a'..'z':for x:='a' to 'z' do
begin
j:=ord(m[i])-97;
k:=ord(x)-97;
l:=(k+j) mod 26+97;
if chr(l)=n[i] then begin write(x); break; end;
end;
end;
end;
end.
好水!(这还是提高组的) -
02012-11-20 17:38:03@
居然不是沙发
-
02012-11-18 10:21:05@
忽略密钥的大小写,于是
if ord(miyue) > 96 then miyue := chr(ord(miyue)-32)
根据公式
ord(mingwen) = ord(miwen) - ord(miyue) + 65
推算出明文的代码
然后检查与密文的大小写是否一致,不一致再+26即可