直接插入排序

来源:互联网 发布:ibeer啤酒软件下载 编辑:程序博客网 时间:2024/06/05 20:34
//============================================================================
// Name        : C++Study.cpp
// Author      : pan
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================


#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <assert.h>
#include <string.h>
using namespace std;


void zj_sort(int a[], int n) {


for (int i = 1; i < n; i++)
for (int j = 0; j < i; j++) {
if (a[i] < a[j]) {
int temp=a[i];
for (int k = i; k > j; k--) {
a[k] = a[k - 1];
}
a[j] = temp;
break;
}
}
}


int main() {


int a[5] = { 2, 4, 1, 3, 5 };
bin_find(a, 5);
for (int i = 0; i < 5; i++)
cout << a[i];
return 0;
}
0 0
原创粉丝点击