Delphida massivlar bilan ishlash algoritmlarga doir misollar 1-masala
Download 257.5 Kb.
|
Delphida ishlash algoritmlarga doir misollar
- Bu sahifa navigatsiya:
- 4.9-masala.
- 4.10-masala.
4.8-masala. N ta elementdan iborat bir o’lchovli massivning elementlari ichida 7 ga teng element borligini aniqlang.
Yechish. Birinchi sikl yordamida massivn elementlarini kirita boramiz va ularning ichida 7 soni bor yoki yo’qligini aniqlaymiz. Ikkinchi sikl yordamida massivn elementlarini bosib chiqaramiz. procedure TForm1.Button1Click(Sender: TObject); VAR N:Integer; begin N:=StrToInt(Edit1.Text); StringGrid1.ColCount:=N; end; procedure TForm1.Button2Click(Sender: TObject); var I,t:byte; begin t:=0; FOR I:=0 TO strtoint(Edit1.Text)-1 DO if strtofloat(stringGrid1.Cells[I,0])=7 then t:=t+1; if t>0 then Edit2.Text:='bor' else Edit2.Text:='yo`q'; end;end. 4.9-masala. N ta elementdan iborat bir o’lchovli massiv berilgan. Bu massiv elementlarining o’rta arifmetik qiymatidan katta bo’lgan elementlar sonini toping. Yechish. Massiv elementlarining o’rta arifmetik qiymatini Z, undan katta bo’lgan massiv elementlari sonini k bilan belgilaymiz. 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]); s:=s/strtoint(Edit1.Text); FOR I:=0 TO strtoint(Edit1.Text)-1 DO if STRTOFLOAT(StringGrid1.Cells[I,0])>s then k:=k+1; Edit2.Text:=inttostr(k); end;end. 4.10-masala. A(N) jadval elementlari ko’paytmasini toping. 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:INTEGER; begin S:=1; FOR I:=0 TO strtoint(Edit1.Text)-1 DO S:=S*STRTOFLOAT(StringGrid1.Cells[I,0]); Edit2.Text:= FloatToStr(S); end; end. Download 257.5 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2025
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling