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
|
Program suppression;
Uses wincrt;
function supp(var s: string;x: integer;y: integer) : string ;
begin
delete(s,x,y-x+1);
supp := s ;
end;
Var ch1 : string ;
x,y : integer ;
Begin
readln(ch1);
repeat
x:= pos('(',ch1);
y := pos(')',ch1);
if (x<y) and (x<> 0) then
ch1 := supp(ch1,x,y) {parenthese ouvrante puis fermante}
else
if y<>0 then
delete(ch1,y,1) {parenthese fermante avant parenthese ouvrante}
else
x := 0 ; {pas de parenthese ouvrante ou fermante}
until (x=0);
writeln(ch1);
End. |
Partager