K
K
Kotorkovsciy2021-12-17 17:41:06
Pascal
Kotorkovsciy, 2021-12-17 17:41:06

How to sort prime numbers in an array in pascal?

program p1;

uses crt;

type
  massive = array of integer;

var
  n: byte;
  i: byte;
  a: massive;

begin
  clrscr;
  write('Введите размер массива:   '); read(n);
  write('Массив: '); 
  setlength(a, n);
  randomize;
  for i := low(a) to high(a) do        
  begin
    a[i] := random(n);        
    write(a[i]:4);
  end;
end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2021-12-17
@HemulGM

Dozens and hundreds of algorithms in the network
For example, I sort like this

var Items := RandomRange(10);
print(Items);
TArrayHelp.Sort(Items);
print(Items);

[0, 3, 86, 20, 27, 67, 31, 16, 37, 42]
[0, 3, 16, 20, 27, 31, 37, 42, 67, 86]

But it won’t work for you, because you need to learn not old languages, but new ones (this is Delphi).
And in your case, you generally need to study the algorithm, and not call functions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question