|
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int temp[9] = { 3, 2, 1, 5, 4, 7, 8, 0, 6 };
int tempCount = 9;
int hold=0,loop,i;
for (loop = 0; loop<tempCount; loop++) {
for (i = 0; i<tempCount-1; i++) {
if (temp[i] > temp[i+1]) {
hold = temp[i];
temp[i] = temp[i+1];
temp[i+1] = hold;
printf("%d", temp[i]);
}
}
}
}
마지막에 버블정렬 된 거를 출력하고 printf문을 썼고... 여기서 Button1을 클릭하면 버블 정렬된 숫자를 나열해서 보여주려면 어떻게 해야 되나요?
|