Pascal/Turbo Pascal - Sumar cuantos SO4 Y CLO3 hay en una cadena INFINITA

 
Vista:

Sumar cuantos SO4 Y CLO3 hay en una cadena INFINITA

Publicado por peryco3 (1 intervención) el 30/03/2017 20:51:49
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
PROGRAM p4;
VAR
c,b,o,cuatro,l,tres,op:char;
a,i:integer;
BEGIN
     write('formula: ');
      read(c);
     a:=0;
     i:=0;
     while not eoln do
           begin
           if (c='S') then
              begin
 
              read(o);
                if (o='O') then
                 begin
                 read(cuatro);
                 if (cuatro='4') then
                    begin
                    a:=a+1;
                    read(c);
                    end
                 else c:=cuatro;
                 end
              else c:=o;
              end
           else read(c);
 
           if (c='C') then
              begin
              read(l);
                if (l='L') then
                 begin
                 read(op);
                 if (op='O') then
                    begin
                    read(tres);
                    if (tres='3') then
                       begin
                       i:=i+1;
                       read(c);
                       end
                    else c:=tres;
                    end
                 else c:=op;
                 end
              else c:=l;
              end;
 
           end;
       write(a,' ',i);
       readln;
       readln;
END.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder