program Fynkuija; uses crt; var l:integer; str,s:string; x,y,q,z,ch:char; procedure prov; const repl1:array[1..6] of string= ('\0','\1','0*0','0*1','1*0','1*1'); repl2:array[1..4] of string= ('0+0','0+1','1+0','1+1'); with1:string='100001'; with2:string='0111'; var p,m,l:integer; begin repeat for l:=1 to length(s) do begin for m:=1 to 6 do begin p:=pos(repl1[m],s); while p<>0 do begin delete(s,p,length(repl1[m])); insert(with1[m],s,p); p:=pos(repl1[m],s); end; end; for m:=1 to 4 do begin p:=pos(repl2[m],s); while p<>0 do begin delete(s,p,length(repl2[m])); insert(with2[m],s,p); p:=pos(repl2[m],s); end; end; end; until (s='0') or (s='1'); end; procedure poisk; var i,j,d:integer; mas:array[1..8,1..3] of char; begin mas[1,1]:='*'; mas[1,2]:='*'; mas[1,3]:='*'; mas[2,1]:='*'; mas[2,2]:='*'; mas[2,3]:='+'; mas[3,1]:='*'; mas[3,2]:='+'; mas[3,3]:='*'; mas[4,1]:='+'; mas[4,2]:='*'; mas[4,3]:='*'; mas[5,1]:='+'; mas[5,2]:='+'; mas[5,3]:='*'; mas[6,1]:='+'; mas[6,2]:='*'; mas[6,3]:='+'; mas[7,1]:='*'; mas[7,2]:='+'; mas[7,3]:='+'; mas[8,1]:='+'; mas[8,2]:='+'; mas[8,3]:='+'; for i:=1 to 16 do begin case i of 1:str:='a b c d'; 2:str:='\a b c d'; 3:str:='\a \b c d'; 4:str:='\a b \c d'; 5:str:='\a b c \d'; 6:str:='\a \b c d'; 7:str:='\a \b \c d'; 8:str:='\a \b c \d'; 9:str:='\a \b \c \d'; 10:str:='a \b c d'; 11:str:='a \b \c d'; 12:str:='a \b c \d'; 13:str:='a \b \c \d'; 14:str:='a b \c d'; 15:str:='a b \c \d'; 16:str:='a b c \d'; end; for j:=1 to 8 do begin for d:=1 to length(str) do begin if str[d]='a'then str[d+1]:=mas[j,1]; if str[d]='b'then str[d+1]:=mas[j,2]; if str[d]='c'then str[d+1]:=mas[j,3]; end; s:=str; for d:=1 to length(str) do begin if s[d]='a'then s[d]:=x; if s[d]='b'then s[d]:=y; if s[d]='c'then s[d]:=q; if s[d]='d'then s[d]:=z end; prov; if s='1' then begin write(str,' ') end; end; end; end; begin repeat Clrscr; writeln(''); writeln('Введите a?',' '); readln(x); writeln('Введите b?',' '); readln(y); writeln('Введите c?',' '); readln(q); writeln('Введите d?',' '); readln(z); poisk; writeln(''); writeln('Запустить прогдамму еще раз? (Y/N)'); readln(ch); until upcase(ch)='N'; end.