#define SIZE 10
int arr[SIZE] = {1, 4, 3, 5, 2, 7, 8, 6, 9, 0};
int i;
int j;
for (i = 0; i< SIZE - 1; i++)
{int iMin = i;
for (j = i + 1; j< SIZE; j++)
{ if (arr[iMin] >arr[j]) { iMin = j;
}
}
int temp = arr[i];
arr[i] = arr[iMin];
arr[iMin] = temp;
}
BubbleSort#define SIZE 10
int arr[SIZE] = {1, 4, 3, 5, 2, 7, 8, 6, 9, 0};
int i, j;
for (i = 0; i< SIZE -1; i++)
{for (j = i + 1; j< SIZE; j++)
{ if (arr[i] >arr[j]) { int temp = arr[i] ;
arr[i] = arr[j];
arr[j] = temp;
}
}
InsertionSort#define SIZE 10
int arr[SIZE] = {1, 4, 3, 5, 2, 7, 8, 6, 9, 0};
int i, j;
for (i = 0; i< SIZE -1; i++)
{for (j = i + 1; j< SIZE; j++)
{ if (arr[i] >arr[j]) { int temp = arr[i] ;
arr[i] = arr[j];
arr[j] = temp;
}
while(i - 1 >= 0 && arr[i]< arr[i - 1])
{ int temp = arr[i];
arr[i] = arr[i - 1];
arr[i - 1] = temp;
}
}
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧