-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject5.bak
70 lines (60 loc) · 2 KB
/
project5.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
program project4;
uses
classes, sysutils,StrUtils;
var
stringA, stringB, stringC: string;
valor:integer;
arquivo: textfile;
linha:string;
tamanho,soma,erro,posicao,i,j,k:integer;
alfa: string;
charigual:char;
jaachei:array of char;
achei:boolean;
begin
alfa:='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
Assign(arquivo,'entrada3.txt');
reset (arquivo);
soma:=0;
achei:=false;
while not eof(arquivo) do
begin
readln(arquivo,stringA );
setlength(jaachei,0);
tamanho:=length(stringa);
stringb:=copy(stringA,1,round(tamanho /2));
stringc:=copy(stringA,round(tamanho/2)+1, round(tamanho/2));
writeln (stringa,' ',stringb,' ',stringc);
for i:=1 to length(stringb) do
begin
charigual:=' ';
for j:=1 to length(stringc) do
begin
writeln ('comparando ',stringb[i],' ' ,stringc[j]);
if stringb[i]=stringc[j] then
begin
charigual:=stringb[i];
write ('achei o caracter ',charigual);
posicao:=pos(charigual, alfa);
writeln ('na posicao ',posicao);
achei:=false;
for k:=0 to length(jaachei) -1 do
begin
if jaachei[k] = charigual then
achei:=true;
end;
write ('achei',achei);
if (not achei) then
begin
write ('entrei');
setlength(jaachei, length(jaachei)+1);
jaachei[length(jaachei)-1]:=charigual;
soma:=soma+posicao;
writeln ('somei. soma atual', soma);
end;
end;
end;
end;
end;
writeln ('achei o valor ' , soma);
end.