有谁知道noip2008普及组第一题怎么做。最好附带解释
pascal吧
全部回复
仅看楼主
level 5
Stephenliu 楼主
2014年11月04日 15点11分 1
level 4
program isbn;
const
inp=*isbn.in*;
oup=*isbn.out*;
var
i,j,k,ans:longint;
s:string;
ch:char;
procedure flink;
begin
assign(input,inp);
reset(input);
assign(output,oup);
rewrite(output);
end;
procedure fclose;
begin
close(input);
close(output);
end;
begin
flink;
readln(s);// 输入字符串
j:=0;
i:=1;
ans:=0;
while j<9 do
begin
if s[i] in [*0*..*9*] then//如果是数字,那么累加到ans中,共9个数字
begin
inc(j);
inc(ans,(ord(s[i])-ord(*0*))*j);
end;
inc(i);
end;
ans:=ans mod 11;计算识别码
if ans=10 then ch:=*X* elsech:=chr(ord(*0*)+ans);//把识别码转换成字符,方便输出
if s[length(s)]=ch
then write(*Right*)
else write(copy(s,1,12)+ch);//输出
正确的
识别码
fclose;
end.
2014年11月06日 10点11分 2
1