> ls
xuanzeSort.c
common.c
> cat common.c
#include<stdio.h>
//公共函数文件
//打印long型数组的内容
void print_array_long(long arr[],long length)
{
long i;
for(i = 0;i<length;i++){
printf("%ld ",arr[i]);
}
printf("\n");
}
> cat xuanzeSort.c
#include<stdio.h>
//选择排序
void selectSort(long *arr,long length){
int i,j,temp;
for(i = 0;i<length;i++){
for(j = i+1;j<length;j++){
if(arr[i]>arr[j]){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
}
//外部声明common.c中的print_array_long函数 打印long型数组
extern void print_array_long(long arr[],long length);
int main()
{
long a[5] = {1,5,88,-1,0};
print_array_long(a,5);
selectSort(a,5);
print_array_long(a,5);
}