| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
发个PASCAL的代码const
a:array [1..10] of integer=(10,9,8,7,6,5,4,3,2,1);
var
s:string;
i,cv:integer;
begin
readln(s);
cv:=0;
for i:=1 to 10 do
if (s[i]<>'?') and (s[i]<>'X') then cv:=(ord(s[i])-48)*a[i]+cv
else if s[i]='X' then cv:=10*a[i]+cv;
cv:=11-(cv mod 11);
if cv=11 then cv:=0;
for i:=0 to 9 do if (a[pos('?',s)]*i) mod 11=cv then begin writeln(i);exit; end;
if ((a[pos('?',s)]*10) mod 11=cv) and (pos('?',s)=10) then
begin writeln('X');exit; end;
writeln(-1);
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator