冒泡排序算法
C++ #include
using namespace std; void swap(int &a, int &b) { a = a + b; b = a - b; a = a - b; } void ergodic(int *p,int length) { for (int i = 0; i
void BubbleSort(int *p, int length) { for (int i = 0; i p[j + 1]) { swap(p[j], p[j + 1]); } } } }
int main(int argc, char *args[]) { int buf[10] = { 12, 4, 34, 6, 8, 65, 3, 2, 988, 45 }; int m = sizeof(buf); cout
BubbleSort(buf, sizeof(buf) / sizeof(int));
cout
}
赞0
踩0