freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c語(yǔ)言四種排序算法時(shí)間復(fù)雜度比較(已修改)

2025-07-07 06:23 本頁(yè)面
 

【正文】 方案設(shè)計(jì): 我這次實(shí)驗(yàn)通過(guò)隨機(jī)生成30000個(gè)隨機(jī)數(shù),把隨機(jī)數(shù)存到數(shù)組中,用這同一組隨機(jī)數(shù)據(jù)分別進(jìn)行四種排序,直接插入排序、直接選擇排序、冒泡排序和快速排序。還通過(guò)了調(diào)用txt文件把運(yùn)算所需時(shí)間導(dǎo)出,分別輸出各個(gè)算法所需用時(shí)并對(duì)用時(shí)時(shí)長(zhǎng)再進(jìn)行冒泡排序算出用時(shí)最短的算法。程序代碼:include include include include include define N 30000void Wrong() //輸入錯(cuò)誤{ printf(\n語(yǔ)法錯(cuò)誤,請(qǐng)重新輸入!\n)。 getchar()。}void Disp(int a[]) //清屏{ int i。 system(cls)。 for(i=0。 iN。 i++) { if((i1)%10==9) printf(\n)。 printf(%7d,a[i])。 }}void InsertSort(int a[],int p) //直接插入排序算法{ int i,j,temp。 for(i=1。 iN。 i++) { temp=a[i]。 for(j=i。 j0amp。amp。a[j1]temp。 j) a[j]=a[j1]。 a[j]=temp。 }}void SelectSort(int a[],int p) //選擇排序算法{ int i,j,k。 for(i=0。 iN1。 i++) { k=i。 for(j=i+1。 jN。 j++) if(a[j]a[k]) k=j。 if(k!=i) { int temp。 temp=a[k]。 a[k]=a[i]。 a[i]=temp。 } }}void BubbleSort(int a[],int p) //冒泡排序算法{ int i,j,temp。 for (i=0。 iN1。 i++) { for (j=N1。 ji。 j) //比較,找出本趟最小關(guān)鍵字的記錄 if (a[j]a[j1]) { temp=a[j]。 //進(jìn)行交換,將最小關(guān)鍵字記錄前移 a[j]=a[j1]。 a[j1]=temp。 } }}void quicksort(int a[],int n,int p) //快速排序算法{ int i,j,low,high,temp,top=1。 struct node { int low,high。 } st[N]。 top++。 st[top].low=0。 st[top].high=n1。 while(top1) { low=st[top].low。 high=st[top].high。 top。
點(diǎn)擊復(fù)制文檔內(nèi)容
語(yǔ)文相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號(hào)-1