bài 16 program bt; var st,st1: string; a: array - TopicsExpress



          

bài 16 program bt; var st,st1: string; a: array [1..100,1..100] of char; i,i1,j,d: longint; kt: boolean; t: char; f: text; begin assign(f,input.txt); reset(f); readln(f,st); readln(f,st1); i:= 1; for i1:= 1 to length(st) do begin if st[i] st1[i] then begin kt:= true; if (st[i] = st1[i+1]) and (st[i+1] = st1[i]) then begin t:= st[i]; st[i]:= st[i+1]; st[i+1]:= t; kt:= false; d:= d+1; a[d,1] := 2; a[d,2] := chr(i+48); a[d,3] := chr(i+1+48); i:= i+1; end; if (st[i] = st1[i+1]) and (kt = true) then begin insert(st1[i],st,i); kt:= false; d:= d+1; a[d,1] := 3; a[d,2] := chr(i-1+48); a[d,3] := st1[i]; i:= i+1; end; if (st[i+1] = st1[i]) and (kt = true) and (st[i+1] st1[i+1]) then begin delete(st,i,1); kt:= false; d:= d+1; a[d,1] := 4; a[d,2] := chr(i+48); end; if kt = true then begin st[i]:= st1[i]; d:= d+1; a[d,1]:= 1; a[d,2]:= chr(i+48); a[d,3]:= st1[i]; i:= i+1; end; end else i:= i+1; end; writeln(st); readln; assign(f,output.txt); rewrite(f); writeln(f,d); for i:= 1 to d do begin for j:= 1 to 3 do write(f,a[i,j], ); writeln(f); end; close(f); end.
Posted on: Sat, 03 Jan 2015 13:38:29 +0000

Trending Topics



Recently Viewed Topics




© 2015