В одномерном массиве А(10) найти номера всех элементов, значение которых – двузначное число — Pascal(Паскаль)

uses
  crt;
const
  max=10;
function Pr(i:integer):boolean;
var
  temp,c:integer;
begin
  temp:=i;
  c:=0;
  while temp<>0 do
  begin
    inc(c);
    temp:=temp div 10
  end;
  Pr:=c=2
end;
var
  a:array[1..max]of integer;
  i:integer;
begin
  clrscr;
  
  writeln('--------:');
  write('[ ');
  for i:=1 to max do
  begin
    a[i]:=random(1000)-500;
    if Pr(a[i]) then
      textcolor(2)
    else
      textcolor(4);
    write(a[i],' ')
  end;
  textcolor(0);
  writeln(']');
 
  writeln('-------: ');
  for i:=1 to max do
    if Pr(a[i]) then
      write(i,' ');
  writeln
end.

Leave a Comment

4 + 4 =