讨论 / QAQ求改正!!!
s952510119 2012-03-08 20:32:00
点我顶贴 收藏 删除
program lx;

var

s,s1:string;

i,l,k,b:integer;

u:longint;

begin

readln(s);

l:=length(s);

k:=1;

for i:=1 to l-1 do

if s[i]<>'-' then

begin

u:=u+(ord(s[i])-48)*k;

k:=k+1;

end;

delete(s,l,1);

u:=u mod 11;

if s[l]='X' then

begin

if u=10 then write('Right')

else begin s:=s+chr(u+48); write(s); halt; end; end

else

b:=ord(s[l])-48;

if u=b then

writeln('Right')

else begin

delete(s,l,1);

if u=10 then begin s:=s+'X';write(s);halt; end

else

s:=s+chr(u+48);

writeln(s);

end;

readln;

end.

为什么总是有两个测试点输出18位呢..

#1 fallenmriver@2012-03-07 06:23:00
回复 删除
这个代码,真心有点难读。。

没这么麻烦的。。你判断嵌套多了容易出问题

拿watches过几遍看看

我把我的贴上

var

t,tot,i:longint;

s:string;

ch:char;

a:array[1..100000]of longint;

begin

readln(s);t:=1;tot:=0;

for i:=1 to 13 do

if s[i]<>'-' then begin

a[t]:=ord(s[i])-48;

inc(t);

end;

for i:=1 to 9 do

tot:=tot+a[i]*i;

tot:=tot mod 11;

if tot=10 then ch:='X'

else ch:=chr(tot+48);

if s[13]=ch then writeln('Right')

else begin

for i:=1 to 12 do write(s[i]);

write(ch);

end;

end.

#2 性徐的人@2012-03-08 20:32:00
回复 删除
士大夫
查看更多回复
提交回复