Pagini recente » Cod sursa (job #804258) | Cod sursa (job #1283878) | Cod sursa (job #1087628) | Cod sursa (job #2000493) | Cod sursa (job #15919)
Cod sursa(job #15919)
program cifra;
const a:array[1..9]of byte=((1),(5),(2),(8),(3),(9),(2),(8),(7));
b:array[1..9]of byte=((7),(4),(1),(8),(5),(2),(9),(6),(3));
var n:array[1..101]of char;
t,i,s,j:integer;
f,h:text;
begin
assign(f,'cifra.in');
assign(h,'cifra.out');
reset(f);rewrite(h);
readln(f,t);
for i:=1 to t do
begin
j:=1;
while not seekeoln(f)do
begin
read(f,n[j]);
inc(j);
end;
case n[j-2] of
'1':s:=b[1];
'2':s:=b[2];
'3':s:=b[3];
'4':s:=b[4];
'5':s:=b[5];
'6':s:=b[6];
'7':s:=b[7];
'8':s:=b[8];
'9':s:=b[9];
else s:=0;
end;
case n[j-1] of
'1':s:=(s+a[1])mod 10;
'2':s:=(s+a[2])mod 10;
'3':s:=(s+a[3])mod 10;
'4':s:=(s+a[4])mod 10;
'5':s:=(s+a[5])mod 10;
'6':s:=(s+a[6])mod 10;
'7':s:=(s+a[7])mod 10;
'8':s:=(s+a[8])mod 10;
'9':s:=(s+a[9])mod 10;
end;
read(f,n[1]);
writeln(h,s);
end;
close(f);close(h);
end.