uses crt; var s:string; c:char; m:set of char; n,i,k,p:byte; begin writeln('Введите текст из строчных латинских букв, окончаание ввода Enter'); s:=''; repeat c:=readkey; if c in ['a'..'z'] then begin write(c); s:=s+c; end; if c=#13 then writeln until c=#13; n:=length(s); m:=[]; for c:='a' to 'z' do begin k:=0; for i:=1 to n do if s[i]=c then k:=k+1; if k>1 then m:=m+[c]; end; if m=[] then write('Нет букв, встречающихся более 1 раза') else for c:='a' to 'z' do if c in m then write(c) end.
Объяснение:
program zadachiGAME;
uses crt;
var a:array [1..59] of array [1..59] of string{integer};
var n,x,y,x1,y1,x3,y3,spawn,x4,y4,x5,y5,Xx,Yy,Xb,Yb,delta1,delta2,deltaGAMER,live:integer; var j:char;label restart1;label otskok1;label otskok2;
begin
restart1:
window (1,1,80,50);
clrscr;
cursoroff;
x1:=35;
y1:=44;
delta1:=1;
delta2:=1;
cursoroff;
live:=10;
y:=50;
x:=25;
deltagamer:=1;
gotoxy(x,y);
x3:=24;
y3:=1;
x4:=6;
y4:=45;
write('press for begin!');
readkey;
gotoxy(X,Y);
write(' ');
n:=1;
spawn:=1;
y3:=1;
x3:=24;
TextColor(3);
for spawn:=1 to 50 do
begin
gotoxy(x3,y3);
writeln('| |');
x3:=24;
y3:=y3+1;
end;
TextColor(11);
gotoxy(40,12);
begin
for y5:=10 to 22 do
for x5:=36 to 44 do
begin
gotoxy(x5,y5);
a[x5,y5]:=('a');
gotoxy(x5,y5);
write ('a');
end;
end;
repeat
begin
delay(53);
x1:=x1+delta1;
y1:=y1+delta2;
gotoxy(x1,y1);
write ('*');
gotoxy(x1+delta1*(-1),y1+delta2*(-1));
write(' ');
if ((x1<>x5) and (y1<>y5)) then //место с присваванием,которое не работает по непонятным причинам
begin
Xx:=x1;
Yy:=y1;
end;
if (a[x1,y1]=('a')) then
begin //проверка для ркошета в разные стороны
if (((x1-Xx)=(-1)) and ((y1-Yy)=(-1)) and ((x1=x5) and (y1=y5)))
then
begin
a[x5,y5]:=('an');
delta1:=delta1*(-1);
end;
if (((x1-Xx)=1) and ((y1-Yy)=(-1)) and ((x1=x5) and (y1=y5)))
then
begin
a[x5,y5]:=('an');
delta2:=delta2*(-1);
end;
end;
TextColor(11);
gotoxy(x4,y4);
begin //отображение некоторых данных
writeln('live - ',live:1);
writeln('Xx ',Xx,'Yy ',Yy);
write ('X1 ',x1,'Y1 ',y1);
end;
TextColor(5);
if (x1=58) or (x1=25) then
delta1:=(-1)*(delta1);
if (y1=2) then
delta2:=delta2*(-1);
if ((y1=y-1) and (x1=x)) or ((y1=y-1) and (x1=x-1)) or ((y1=y-1) and (x1=x+1)) or ((y1=y-1) and (x1=x+2)) or ((y1=y-1) and (x1=x+3)) then
delta2:=delta2*(-1)
else
if ((y1=y) and (x1<>x)) or ((y1=y) and (x1<>x-1)) or ((y1=y) and (x1<>x+1)) or ((y1=y) and (x1<>x+2)) or ((y1=y) and (x1<>x+3)) then
begin
gotoxy(x1,y1);
write(' ');
delta2:=delta2*(-1);
y1:=y1+delta2-1;
live:=live-1;
end;
TextColor(13);
if keypressed then
begin
//if keypressed then
j:=readkey;
case j of
#77:deltaGAMER:=3;//вправо
#75:deltaGAMER:=(-3);//влево
#27:Exit;
else
deltagamer:=(0);
end;
if (x=25) or ((x>55) and (x<59)) then
deltagamer:=(-1)*(deltagamer);
if (x=25) and (j=#77) or (x=56) and (j=#75)then
deltagamer:=(-1)*(deltagamer);
x:=x+(1*deltaGamer);
if j<> #75 then
begin
gotoxy(x,y);
write ('---');
end;
if j<> #77 then
begin
gotoxy(x,y);
write ('---');
end
else
gotoxy(x+deltagamer*(-1),wherey);
write(' ');
gotoxy(x,y);
end;
end;
until live=0;
begin
clrscr;
gotoxy(37,25);
writeln (' Defith');
gotoxy(37,27);
writeln (' press "r" for restart');
j:=readkey;
case j of
#114:goto restart1;
#82:goto restart1;
#170:goto restart1;
#138:goto restart1;
#27:end;
end;
end.