标签:i++ 排序 swa namespace wap names list 冒泡 pac
看见了一些乱乱的东西,就想着整理一下,基础的冒泡排序
//BubbleSort #include<iostream> using namespace std; void BubbleSort(int list[],int n) { for(int i=0; i<n-1; i++) { for(int j=0; j<n-i-1; j++) { if(list[j]>list[j+1]) swap(list[j],list[j+1]); } } } int main() { int a[]= {2,3,4,6,3,1,8,9}; BubbleSort(a,8); for(int i=0; i<8; i++) { cout<<a[i]<<" "<<endl; } return 0; }
标签:i++ 排序 swa namespace wap names list 冒泡 pac
原文地址:https://www.cnblogs.com/chuxinbubian/p/11306291.html