|
int n;
n=StrToInt(Edit1->Text )
|
bet | 5/5 | Sana | 20.05.2024 | Hajmi | 208,13 Kb. | | #244829 |
Bog'liq 21- lectures Basic prog Massivint n;
n=StrToInt(Edit1->Text );
StringGrid1->Cells[0][0]="A massiv" ;
StringGrid2->Cells[0][0]="B massiv" ;
StringGrid1->ColCount =n+1;
StringGrid2->ColCount =n+1;
Endi Button2 ning onClick xossasiga quyidagi kodni kiritamiz.
int n,c;
n=StrToInt(Edit1->Text );
int a[100];
for (int i=1;i<=n;i++)
a[i]=StrToInt(StringGrid1->Cells [i][0]);
for (int k=1;k<=n;k++)
for(int i=1;i<=n-1;i++)
if (a[i]>a[i+1])
{ c=a[i];
a[i]=a[i+1];
a[i+1]=c ;
};
for (int i=1;i<=n;i++)
StringGrid2->Cells [i][0]=IntToStr(a[i]) ;
Endi dasturni ishlatish uchun “Run” menyusining “Run” buyrig’ini yoki klaviaturadan F9 klavishini bosib ishgatushirishimiz mumkin. Shunda bizga quyidagicha oyna xosil bo’ladi.
Bu dasturni ishlatish uchun avval n ga qiymat berib “Massivni shakllantirish“ buyrug’i orqali massivni shakllantirib so’ngra massivni qiymatini berib “tartiblash” buytug’ini tanlaymiz. Masalan:
|
| |