Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <iostream>
- #pragma hdrstop
- #include <string.h>
- #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)
- {
- int sm = ComboBox1 -> ItemIndex;
- String s = ComboBox1 -> Items -> Strings[sm];
- char * z = s.c_str();
- int n = 0;
- char * num = strtok (z, " ");
- while (num)
- {
- n++;
- num = strtok (NULL, " ");
- }
- int * A = new int [n];
- num = strtok (z, " ");
- for (int i = 0; i<n; i++)
- {
- A[i]= atoi(num);
- num = strtok (NULL, " ");
- }
- for (int i = 0; i<n-1; i++)
- {
- for(int j = 0; j<n-i-1; j++)
- {
- if (A[j] > A[j+1])
- {
- int temp = A[j];
- A[j] = A [j+1];
- A [j+1] = temp;
- }
- }
- }
- String result = String (A[0]);
- for (int i = 1; i<n; i++)
- {
- result += " " + String (A[i]);
- }
- ComboBox1 -> Items -> Add(result);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- ComboBox1 -> Items -> Add(ComboBox1 -> Text);
- ComboBox1 -> Text = "";
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement