Цитата:
Сообщение от 11Angelav
Язык программирования не указали.
|
Ладно, на основании помещения в раздел будем считать, что Паскаль. Тогда так:
Код:
Var
M1,M2,M3,M4:Set of Byte;
i:Byte;
YN:Char;
b:boolean;
Begin
M1:=[];
M2:=[];
Writeln('Set1:');
Repeat
Write('Next element: ');
Readln(i);
M1:=M1+[i];
Write('Continue? (Y/N): ');
Readln(YN);
Until (YN='N') or (YN='n');
Writeln;
Writeln('Set2:');
Repeat
Write('Next element: ');
Readln(i);
M2:=M2+[i];
Write('Continue? (Y/N): ');
Readln(YN);
Until (YN='N') or (YN='n');
Writeln;
M3:=M1-M2;
M4:=M2-M1;
b:=(M3<>[]) or (M4<>[]);
If b then
begin
if M3<>[] then
begin
Writeln('Not coinciding elements of Set1:');
for i:=0 to 255 do
if (i in M1) and Not(i in M2) then write(i:4);
Writeln;
end;
if M4<>[] then
begin
Writeln('Not coinciding elements of Set2:');
for i:=0 to 255 do
if Not(i in M1) and (i in M2) then write(i:4);
end;
end
else
Writeln('Sets coicide');
Readln
End.