数字加密解密
发布网友
发布时间:2022-04-25 09:48
我来回答
共2个回答
热心网友
时间:2023-12-02 03:29
var a:array[0..9]of byte=(0,1,2,3,4,5,6,7,8,9); {定义原始数字}
b:array[0..9]of byte=(7,5,9,1,3,6,8,0,2,4);{定义密文数字}
c:array[1..100]of byte;{待处理数字}
n,m,i,j:longint;
begin
read(n,m);
for i:=1 to m do
read(c[i]);{读入待处理数字}
if n=1 then{加密}
for i:=1 to m do
write(b[c[i]]);{原始数字是0,1,2,3,4,5,6,7,8,9所以不需寻找}
if n=2 then{解密}
for i:=1 to m do
for j:=0 to 9 do{寻找原始数字}
if c[i]=b[j] then
write(a[j],' ');
end.
纯手打!
Free pascal 测试通过!
Running "d:\▒α│╠ ╣¿╩╦╞µ\fpc\bin\i386-win32\ys.exe 123"
1 6
1 9 9 7 7 1
Running "d:\▒α│╠ ╣¿╩╦╞µ\fpc\bin\i386-win32\ys.exe 123"
2 6
1 9 9 7 7 1
3 2 2 0 0 3
望楼主采纳! 谢谢!
热心网友
时间:2023-12-02 03:30
百度一下,就知道了