7_4.cpp

来自「本文档是(作者:钱能)《C++程序设计教程》课后习题答案。 选题编辑:张朝阳 」· C++ 代码 · 共 17 行

CPP
17
字号
//7_4

void Swap(int& a, int& b){ int temp=a; a=b; b=temp; }

void Bsort(int a[], int n)
{
  bool dontLoopAgain=false;
  while(dontLoopAgain=!dontLoopAgain)
    for(int i=0,pass=--n; i<n; i++)
      if(a[i]>a[i+1]){
        dontLoopAgain=false;
        Swap(a[i],a[i+1]);
      }
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?