prepair.c

来自「此程序改自算法课的一个作业」· C语言 代码 · 共 52 行

C
52
字号
/*****************************************************Zhang Pengpeng (rocflyhi@gmail.com)   from Colleage of Information Science and Technology Nanjing University of Aeronautics and Astronautics Comment: This program comes form my algorithm homework which is modified for linux and GCC.*****************************************************/#include "sort.h"#include <stdio.h>#include <time.h>/********************Follow is preparation*********************/void getArr()		/*produce random array*/{	int i;	srand (time(NULL));	for(i=0;i<numArr;i++)		Arr[i]=rand();}void copyArr()	/*copy date to protect original date*/{	int i;	for(i=0;i<numArr;i++)		A[i]=Arr[i];}void statistics(int sortMode)/*get average sortMode is the sort method*/{	double sum=0;	int compCount;	for(compCount=0;compCount<numArr;compCount++)		sum+=compPerSort[sortMode][compCount];	countAver[sortMode]=sum/numArr;}void output()		/*print the result*/{	int sortMode;	printf("Now print the average times of comparison \neach sort_algorithm take to deal with %d random numbers\n",numArr);	printf("SELECTIONSORT,INSERTIONSORT, BOTTOMUPSORT,    MERGESORT,    QUICKSORT\n");	for(sortMode=0;sortMode<5;sortMode++)		printf("%13.2f,",countAver[sortMode]);	printf("\n");}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?