数据结构课程设计
附录 源程序清单
#include<iostream.h> #include<iomanip.h> #include<stdlib.h> #include<stdio.h> #include<time.h> #define N 100 int p,q; //起泡排序
void gensort(int b[],int n) {
int i,j;int s=0,t=0; for(i=0;i<n-1;i++) {
for(j=i+1;j<n;j++) { t++;
if(b[i]>b[j]) {
int temp=b[i]; b[i]=b[j]; b[j]=temp; s+=3; }}}
cout<<"移动次数="<<s<<","<<"比较次数="<<t<<endl; }
//插入排序
typedef int KeyType;
struct rec {
KeyType key; };
typedef rec sqlist[N];
void insertsort(sqlist b,int n) {
int i,j;int s=0,t=0; for(i=2;i<n;i++)
14
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库课程设计——内部排序算法比较(14)在线全文阅读。
相关推荐: