Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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, " ");
- }
- Memo1->Lines->Add(s);
- 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 = IntToStr(A[0]);
- for (int i = 1; i<n; i++)
- {
- Memo1->Lines->Add("P = " + IntToStr(A[i]));
- result += " " + IntToStr(A[i]);
- }
- ComboBox1 -> Items -> Add(result);
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement