ð
来自「最近对排序算法的复习」· 代码 · 共 38 行
TXT
38 行
// 冒泡排序.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
void Swap(int &x,int &y) {
int temp = x;
x = y;
y = temp;
}
void mppx(int array[],int length) {
for(int i = 0;i<length;i++) {
for(int j = 0;j < length-i;j++) {
if(array[j]>array[j+1]) {
Swap(array[j],array[j+1]);
}
}
}
}
int main(int argc, char* argv[])
{
int array[] = {23,54,12,34,97,60,58,7,73,82};
for(int i=0;i<10;i++) {
cout<<array[i]<<" ";
}
cout<<endl;
mppx(array,10);
for(i=0;i<10;i++) {
cout<<array[i]<<" ";
}
cout<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?