来位PASCAL高手啊

来源:百度知道 编辑:UC知道 时间:2024/09/25 07:37:45
var n,i,j,tot:longint;
f:array[0..27] of longint;
a:array[0..26] of char;
c:char;
begin
fillchar(f,sizeof(f),0);
readln(n);
for i:=n downto 1 do
begin
for j:=i+1 to n do f[i]:=f[i]+f[j];
inc(f[i]);
end;
tot:=0; j:=0; a[0]:=’@';
while not eoln do
begin
inc(j); read(a[j]);
for i:=ord(a[j-1])-64+1 to ord(a[j])-64-1 do
tot:=tot+f[i];
inc(tot);
end;
writeln(tot);
end.
高手帮我把这个程序解释一下

var n,i,j,tot:longint;
f:array[0..27] of longint;
a:array[0..26] of char;
c:char;
begin
fillchar(f,sizeof(f),0); {初始化数组}
readln(n);
for i:=n downto 1 do {根据n产生偏移量,n不能超过26,n越大偏移值f[i]越大}
begin
for j:=i+1 to n do f[i]:=f[i]+f[j];
inc(f[i]);
end;
tot:=0; j:=0; a[0]:=’@'; {初始化,’@'前面引号应该是中文的,得把它换成英文的}
while not eoln do {跟据a[j]里保存的字符和偏移量产生8个数字}
begin
inc(j); read(a[j]);
for i:=ord(a[j-1])-64+1 to ord(a[j])-64-1 do
tot:=tot+f[i];
inc(tot);
end;
writeln(tot);
end.
这个程序应该是类似于随机产生8个电话号码的,不同的是这里没随机,而是跟据输入字符和偏移量产生8个0-9的数字,要看运行过程自己按F7。