Please help me write a program for turbo pascal using an array. There is a one-dimensional array of whole random numbers consisting of N=20 elements. The program should answer the question: “Is it true that the first number is less than the others?

 Program L15; var a,b,c,d:integer; begin writeln('Введите 4 числа'); readln(a,b,c,d); if ( (a<b) and (a<c) and (a<d) ) then writeln('Да') else writeln('Нет'); end. 

the rest through for, while, repeat.

  • one
    Are you going to write all 20 elements through a, b, c, d ...? what would you suggest, you must at least have basic concepts. An array is a separate data type, not a comma-separated variable. I do not like to send there but, bit.ly/Vfm5sc - Gedweb

1 answer 1

Here is the solution:

 Program L15; var m:array [1..20] of integer; i:integer; f:Boolean; begin f:=true; for i:=1 to 20 do begin writeln('Введите числo #'+IntToStr(i)); readln(m[i]); end; for i:=2 to 20 do begin if m[1]>m[i] then f:=False; end; if f then writeln('Да первое число меньше остальных') else writeln('Нет, первое число не меньше остальных'); end. 
  • it wouldn’t have been a bad idea to screw the random one, instead of manual input - Gedweb
  • Well, if you gently fill in with random numbers, then the string writeln ('Enter the number #' + IntToStr (i)) is enough; readln (m [i]); Replace with Randomize; m [i]: = Random (100); - vdk company