- ISBN号码
- 2015-01-28 15:46:57 @
var
i,b,c: Longint;
d,f: String;
a: array[1..10] of Integer;
e: array[1..13] of Char;
begin
readln(d);
a[1]:=ord(d[1]);
for i := 2 to 4 do
begin
a[i]:=ord(d[i+1]);
end;
for i := 5 to 9 do
begin
a[i]:=ord(d[i+2]);
end;
a[10]:=ord(d[13]);
for i := 1 to 10 do
begin
b:=a[i]*i;
end;
b:=(b mod 11);
Str(a[1],e[1]);
e[2]:=('-');
for i := 3 to 5 do
begin
Str(a[i-1],e[i]);
end;
e[6]:=('-');
for i := 7 to 11 do
begin
Str(a[i-2],e[i]);
end;
e[12]:=('-');
if b=10 then
begin
e[13]:=('X');
end
else
begin
Str(b,e[13]);
end;
for i := 1 to 13 do
begin
f:=f+e[i];
end;
if d=e then
begin
write('Right');
end
else
begin
write(e);
end;
end.
1 条评论
-
q234rty LV 10 @ 2015-01-28 17:42:04
str这个过程需要一个数字和一个字符串,但不能是字符,如果想把一个数字转化成字符,可以这样写:
var
a,temp:longint;
c:char;
begin
readln(a);
temp:=a+48; //计算a的ascii码,‘0’的ascii码是48
c:=chr(temp); //chr函数把ascii码转换成字符
writeln(c);
end.
- 1