Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

发个PASCAL的代码

Posted by demaxiya at 2012-08-21 10:32:25 on Problem 2190
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator