SGU 179 — Brackets light
找到最靠后的一个满足它左边的’(’比’)’数量多的’(’,改成’)’,然后在后面补(…()…)和)…).好久以前就写过的题.刚才写错了一点,在最后填括号的时候先填(…()…),再填)…).
{ SGU 179; Brackets light - sqybi’s code}//for my winstyprogram sgu179_sqybi; var i, l, r, tr, t: longint; s: ansistring;
begin readln(s); l := length(s); t := 0; r := 0; for i:=1 to l do begin if (t > 0) and (s[i] = ‘(’) then begin tr := t; r := i; end; […]