📄 ð
字号:
// 冒泡排序.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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -