int n; n=StrToInt(Edit1->Text )




Download 208,13 Kb.
bet5/5
Sana20.05.2024
Hajmi208,13 Kb.
#244829
1   2   3   4   5
Bog'liq
21- lectures Basic prog Massiv

int 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:


1 https://uz.wikipedia.org/wiki/Massiv

2 https://docs.dot-net.uz/c-.net/basic/essential/massiv

Download 208,13 Kb.
1   2   3   4   5




Download 208,13 Kb.