Cod sursa(job #26384)

Utilizator cristi_oocnean cristian cristi_o Data 5 martie 2007 15:30:43
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.82 kb
program _07_2;
type sir=array [1..100] of longint;
var a:sir;
    f,g:text;
    t:integer;

procedure citire;
var i:integer;
begin
assign (f,'cifra.in'); reset (f);
read (f,t);
for i:=1 to t do readln (f,a[i]);
close (f);
end;

function calcul (x:byte):byte;
var i:integer;
begin
if x=1 then calcul:=1 else
if x=2 then calcul:=4 else
if x=3 then calcul:=7 else
if x=4 then calcul:=6 else
if x=5 then calcul:=5 else
if x=6 then calcul:=6 else
if x=7 then calcul:=3 else
if x=8 then calcul:=6 else
if x=9 then calcul:=9 else
if x=0 then calcul:=0
end;

procedure tiparire;
var i,j,s:integer;
begin
assign (g,'cifra.out'); rewrite (g);
for i:=1 to t do begin
   s:=0;
   for j:=1 to a[i] do s:=s+calcul (j mod 10);
   writeln (g,s mod 10)
   end;
close (g);
end;

begin
citire;
tiparire;
end.