Delphida massivlar bilan ishlash algoritmlarga doir misollar 1-masala
Download 257.5 Kb.
|
Delphida ishlash algoritmlarga doir misollar
- Bu sahifa navigatsiya:
- 4.2-masala
- 4.3-masala.
- 4.4-masala.
Delphida massivlar bilan ishlash algoritmlarga doir misollar 4.1-masala. A(1), A(2)….,A(N) ketma-ketlikda berilgan jadval elementlarini teskari tartibda ekranga chiqaring. procedure TForm1.Button1Click(Sender: TObject); begin N:=StrToInt(Edit1.Text); StringGrid1.ColCount:=N; StringGrid2.ColCount:=N; end; procedure TForm1.Button2Click(Sender: TObject); var a,a1,k:real;I:byte; begin for I:=0 TO n-2 div 2 DO begin a:=StrToFloat(StringGrid1.Cells[i,0]); a1:=StrToFloat(StringGrid1.Cells[n-i-1,0]); begin k:=a;a:=a1;a1:=k; StringGrid2.Cells[i,0]:=FloatToStr(a); StringGrid2.Cells[i+1,0]:=FloatToStr(a1); end;end;end; end. 4.2-masala. N ta elementdan tashkil topgan massivning elementlari yig’indisini toping. procedure TForm1.Button1Click(Sender: TObject); begin N:=StrToInt(Edit1.Text); StringGrid1.ColCount:=N; end; procedure TForm1.Button2Click(Sender: TObject); begin S:=0; FOR I:=0 TO n-1 DO S:=S+STRTOFLOAT(StringGrid1.Cells[I,0]); Edit2.Text:= FloatToStr(S); end; end. 4.3-masala. N ta elementdan iborat bir o’lchovli massiv elementalarini kiritng va ularni ekranga chiqaring. Yechish. Birinchi sikl yordamida massiv elementalarini kiritamiz. Ikkinchi sikl yordamida ularni ekranga chiqaramiz. procedure TForm1.Button1Click(Sender: TObject); begin N:=StrToInt(Edit1.Text); StringGrid1.ColCount:=N; end; procedure TForm1.Button2Click(Sender: TObject); begin Memo1.Clear; FOR I:=0 TO n-1 DO memo1.Lines.Add(inttostr(i+1)+'-element '+StringGrid1.Cells[i,0]); end; end. 4.4-masala.N ta elementdan iborat bir o’lchovli massaviy elementlarning yig’indisi S va manfiy elementlar soni K ni aniqlang. Yechish. Birinchi sikl yordamida massiv elementalarini kiritamiz. Ikkinchi sikl yordamida massiv elementalarining yig’indisini hamda manfiy elementlar sonini hisoblaymiz. procedure TForm1.Button1Click(Sender: TObject); VAR N:Integer; begin N:=StrToInt(Edit1.Text); StringGrid1.ColCount:=N; end; procedure TForm1.Button2Click(Sender: TObject); var S:REAL; I,k:INTEGER; begin S:=0;k:=0; FOR I:=0 TO strtoint(Edit1.Text)-1 DO S:=S+STRTOFLOAT(StringGrid1.Cells[I,0]); Edit2.Text:= FloatToStr(S); FOR I:=0 TO strtoint(Edit1.Text)-1 DO if STRTOFLOAT(StringGrid1.Cells[I,0])<0 then k:=k+1; Edit3.Text:=inttostr(k); end; end. 0> Download 257.5 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling