| ||||||||||
| 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 | |||||||||
Re:顶起PASCAL!In Reply To:顶起PASCAL! Posted by:875319120 at 2012-08-27 15:11:38 LZSB
const
b:array [1..7] of byte=(9,3,7,9,3,7,9);
var
i,j,k,n,t,cc:integer;
s:string;
a:array [1..7] of byte;
begin
readln(n);
for i:=1 to n do
begin
readln(s);
for j:=1 to length(s) do if s[j]='?' then a[j]:=10
else a[j]:=ord(s[j])-48;
k:=0;
cc:=0;
for j:=length(s) downto 1 do begin inc(cc);if a[j]<>10 then k:=k+a[j]*b[cc]; end;
k:=k mod 10;
k:=10-k;
t:=pos('?',s);
t:=length(s)-t+1;
for j:=0 to 9 do if ((j*b[t]) mod 10)=k then begin a[pos('?',s)]:=j;break; end;
writeln('Scenario #',i,':');
for j:=1 to length(s) do write(a[j]);
writeln;
writeln;
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator