标签:ble str 数组 log pac 冒泡 public div ++
#include<iostream> using namespace std; class BubbleSort { public: int* bubbleSort(int* A, int n) { // write code here //c++求数组长度:sizeof(array) / sizeof(array[0]) for (int i = 0; i<n; 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; } } return A; } }; int main() { int n = 10; int a[10]; for (int i = 0; i<n; i++) { cin >> a[i]; } BubbleSort b; b.bubbleSort(a, n); cout << "排好的数为:" << endl; for (int i = 0; i<n; i++) cout << a[i] << "\t"; cout << endl; system("pause"); return 0; }
标签:ble str 数组 log pac 冒泡 public div ++
原文地址:http://www.cnblogs.com/fanru5161/p/7425037.html