program acme_dna_match; uses crt; const maxcol=100; maxlin=50; type dnastr = string[maxcol]; dnavit = array [1..maxlin] of dnastr; function dnamatch (var DNA:dnavit; var F:dnastr; lin,col,posic:integer): boolean; begin if (DNA[lin][col] <> F[posic]) and (DNA[lin][col]<>'N') and(F[posic]<>'N') then dnamatch:=false else if (col = length(DNA[lin])) and (posic < length(F)) then dnamatch:=false else if posic = length(F) then dnamatch:=true else dnamatch:=dnamatch(DNA,F,lin,col+1,posic+1); end; var arqvit: text; arqsusp: text; narqvit: string; narqsusp:string; dadosvit:dnavit; fragmento:dnastr; cabecalho:dnastr; lin,col,l,c:integer; posic:integer; totlin:integer; achou,ok:boolean; begin clrscr; writeln('>> ACME Dna-Buster <<'); writeln('>> Digital DNA Detective <<'); writeln; write ('Arquivo DNA vitima: '); readln(narqvit); assign(arqvit,narqvit); reset(arqvit); readln(arqvit,cabecalho); writeln('Dados da vitima: ',cabecalho); totlin:=0; while not(eof(arqvit)) do begin totlin:=totlin+1; readln(arqvit,dadosvit[totlin]); end; close(arqvit); writeln('Dados do DNA da vitima lidos...'); writeln; write ('Arquivo DNA suspeito: '); readln(narqsusp); assign(arqsusp,narqsusp); reset(arqsusp); readln(arqsusp,fragmento); writeln('DNA:',fragmento); writeln('Dados do fragmento de DNA suspeito lidos...'); close(arqsusp); writeln; writeln('# Processando dados - Match de DNA #'); achou:=false; ok:=false; for lin:=1 to totlin do begin posic:=1; write('VIT[',lin,']:',dadosvit[lin]); for col:=1 to length(dadosvit[lin]) do begin if dadosvit[lin][col] = fragmento[1] then achou:=dnamatch(dadosvit,fragmento,lin,col,posic); if achou then begin ok:=true; l:=lin; c:=col; end end; if ok then writeln(' #OK# ') else writeln(' @NO@ '); delay(100); end; writeln; if ok then begin writeln('Resultado...'); writeln('Casamento de DNA - CONFIRMADO'); writeln('Posicao: Linha = ',l,' - Coluna = ',c); end else begin writeln('Resultado...'); writeln('Casamento de DNA - NAO CONFIRMADO'); end; writeln; writeln('>> ACME DNA-Buster agradece a preferencia <<'); readln; end.