3、main头文件: main.h
#ifndef MAIN_H #define MAIN_H #include<stdio.h> #include "quickSort.h" int main(void); void showArr(const int *pArr, const int length); void initRandomArr(int *pArr, const int length); #endif4、main源文件:main.c
#include "main.h" int main(void) { printf("Input array length:\n"); int length; scanf("%d", &length); if(length<0) { printf("Array length must be larger 0\n"); return 1; } int arr[length]; initRandomArr(arr, length); printf("Get random array :\n"); showArr(arr, length); quickSort(arr, length); printf("quick sort result:\n"); showArr(arr, length); return 0; } void showArr(const int *pArr, const int length) { int i; for(i=0; i<length; i++) { printf("%d ", *(pArr+i)); } printf("\n"); } void initRandomArr(int *pArr, const int length) { int i; srand(time(NULL)); for(i=0; i< length; i++) { *(pArr+i)=rand()%1000; } }