type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; Button1: TButton; Edit2: TEdit; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; A:array of shortint; implementation
{$R *.dfm}
Function P(A:integer):boolean; Var d,K:integer; Begin P:=true; if A < 2 then P:=false else if A < 4 then P:=true else if A mod 2 = 0 then P:=false else Begin K:=Trunc(Sqrt(A)); d:=3; While d <= K do Begin if A mod d = 0 then P:=false; d:=d+2 End; End; End;
procedure TForm1.Button1Click(Sender: TObject); Var N:integer; begin Randomize; Edit2.Text:=''; N:=StrToInt(Edit1.Text); SetLength(A,N); For N:= 0 to N-1 do Begin A[N]:=Trunc(Sin(random(20))*20); if P(A[N]) then Edit2.Text:=Edit2.Text+IntToStr(A[N])+'0 ' else Edit2.Text:=Edit2.Text+IntToStr(A[N])+' ' End; end;
end.
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota
Оформи подписку