AÇIKLAMA
C++ Builder 6 ile uyumludur.Bu programda ListBox bileşeni içine eklenen sayıların istenilen moda göre sıralanması yapılmıştır. Sayılar eklendikten sonra RadioButton yardımıyla istenilen mod (Artan , Azalan) seçilir. ListBox içindeki sayılar buna uygun biçimde tekrardan sıralanırlar.
Programın Tamamını Aşağıdaki Linkten İndirebilirsiniz
Linki Görebilmeniz İçin Üye Olmanız Gerekmektedir...
Üye Kayıt
Program Kodu:
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { if(Edit1->Text!="") { ListBox1->Items->Add(Edit1->Text); Edit1->Text=""; } else Application->MessageBox("Bir Sayı Giriniz","UYARI",MB_ICONINFORMATION); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { if(RadioButton1->Checked || RadioButton2->Checked) { if(RadioButton1->Checked) { for(int i=0;i<ListBox1->Items->Count;i++) { for(int j=i+1;j<ListBox1->Items->Count;j++) { if(StrToInt(ListBox1->Items->Strings[i])>StrToInt(ListBox1->Items->Strings[j])) { int temp=StrToInt(ListBox1->Items->Strings[i]); ListBox1->Items->Strings[i]=ListBox1->Items->Strings[j]; ListBox1->Items->Strings[j]=temp; } } } } else { for(int i=0;i<ListBox1->Items->Count;i++) { for(int j=i+1;j<ListBox1->Items->Count;j++) { if(StrToInt(ListBox1->Items->Strings[i])<StrToInt(ListBox1->Items->Strings[j])) { int temp=StrToInt(ListBox1->Items->Strings[i]); ListBox1->Items->Strings[i]=ListBox1->Items->Strings[j]; ListBox1->Items->Strings[j]=temp; } } } } } else Application->MessageBox("Sıralama Modunu Seçiniz","UYARI",MB_ICONINFORMATION); } //---------------------------------------------------------------------------