program NaturalNumbersWithDigit; var i, digit: integer; begin write('Enter a digit: '); readln(digit); if (digit < 0) or (digit > 9) then writeln('Invalid input. Please enter a single digit from 0 to 9.') else begin writeln('The natural three-digit numbers containing the digit ', digit, ' are:'); for i := 100 to 999 do begin if (i div 100 = digit) or ((i div 10) mod 10 = digit) or (i mod 10 = digit) then writeln(i); end; end; end.
var
i, digit: integer;
begin
write('Enter a digit: ');
readln(digit);
if (digit < 0) or (digit > 9) then
writeln('Invalid input. Please enter a single digit from 0 to 9.')
else begin
writeln('The natural three-digit numbers containing the digit ', digit, ' are:');
for i := 100 to 999 do
begin
if (i div 100 = digit) or ((i div 10) mod 10 = digit) or (i mod 10 = digit) then
writeln(i);
end;
end;
end.
Пример вывода:
Enter a digit: 5The natural three-digit numbers containing the digit 5 are:
105
115
125
135
145
150
151
152
153
154
155
156
157
158
159
205
215
225
235
245
250
251
252
253
254
255
256
257
258
259
305
315
325
335
345
350
351
352
353
354
355
356
357
358
359
405
415
425
435
445
450
451
452
453
454
455
456
457
458
459
505
515
525
535
545
550
551
552
553
554
555
556
557
558
559
605
615
625
635
645
650
651
652
653
654
655
656
657
658
659
705
715
725
735
745
750
751
752
753
754
755
756
757
758
759
805
815
825
835
845
850
851
852
853
854
855
856
857
858
859
905
915
925
935
945
950
951
952
953
954
955
956
957
958
959