/*
* 程序的版权和版本声明部分
* Copyright (c)2013, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: fibnacci.cpp
* 作 者:初瑞
* 完成日期: 2013 年12 月 6 日
* 版本号: v1.0
* 输入描述:无
* 问题描述:数组的排列选择法
* 程序输出:
* 程序输出:
* 问题分析:
*/
#include <iostream>
using namespace std;
int main()
{
void bubble_sort(int array[],int n);
void output_array(int array[],int n);
void bubble_sort(int array[],int n);
void output_array(int array[],int n);
int a[20]= {86,76,62,58,77,85,92,80,96,88,77,67,80,68,87,64,59,61,76};
int b[15]={27,61,49,88,4,20,28,31,42,62,64,14,88,27,73};
bubble_sort(a,20);
output_array(a,20);
bubble_sort(b,15);
output_array(b,15);
return 0;
}
void bubble_sort(int array[],int n)
{
int i,j,k,t;
for(i=0; i<n-1; i++)
{
k=i;
for(j=i+1; j<n; j++)
if(array[j]<array[k])
k=j;
t=array[k];
array[k]=array[i];
array[i]=t;
}
}
void output_array(int array[],int n)
{
for(int i=0; i<n; i++)
cout<<array[i]<<" ";
cout<<endl;
}
运算结果: