СРОЧНО! Решение делается в турбо паскале:
"Вывести на экран все четырехзначные числа, в записи которых нет одинаковых цифр!"
var s:string;
i,j,k:integer;
Unique:boolean;
BEGIN
for i := 1000 to 9999 do
begin
s := str(i);
Unique:=true;
for j: = 1 to length(s)-1 do
for k := j+1 to length(s) do
if s[j] = s[k] then Unique:=false;
end;
if Unique then
writeln(i);
END.
может длинее, но универсальное.
var a: integer; c1, c2, c3, c4: integer;
begin for a := 1000 to 9999 do begin c1 := a div 1000; c2 := (a div 100) mod 10; c3 := (a div 10) mod 10; c4 := a mod 10; if (c1 <> c2) and (c1 <> c3) and (c1 <> c4) and (c2 <> c3) and (c2 <> c4) and (c3 <> c4) then writeln(a); end;end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
var s:string;
i,j,k:integer;
Unique:boolean;
BEGIN
for i := 1000 to 9999 do
begin
s := str(i);
Unique:=true;
for j: = 1 to length(s)-1 do
for k := j+1 to length(s) do
begin
if s[j] = s[k] then Unique:=false;
end;
if Unique then
writeln(i);
end;
END.
может длинее, но универсальное.
Verified answer
var
a: integer;
c1, c2, c3, c4: integer;
begin
for a := 1000 to 9999 do
begin
c1 := a div 1000;
c2 := (a div 100) mod 10;
c3 := (a div 10) mod 10;
c4 := a mod 10;
if (c1 <> c2) and (c1 <> c3) and (c1 <> c4) and (c2 <> c3) and (c2 <> c4) and (c3 <> c4)
then writeln(a);
end;
end.