各種排序的實現 求人解惑一下

2021-08-13 13:21:18 字數 1211 閱讀 3112

#include

#include

#include

#include

#include

using namespace std; 

#define t 1000; 

bool cmp(int a,int b) //重寫sort()的比較函式    

void swap(int &a,int &b) 

//直接插入排序

void insertsort(int a,int length)

} //希爾排序

void shellsort(int a,int length)

a[k+gap] = temp; }

} }

//起泡排序

void simsort( int a, int length)

} }

} //快速排序

void quicksort(int a,int length,int right) 

cout<>m1; 

if(!m1) break; 

else   a[m++]=m1; 

}  cout<<"       請按編號選擇所需排序演算法     "<>k; 

if(k<1||k>6) 

cout<<"輸入有誤!請重新輸入: "; 

else 

break; 

}  flag2=0; 

switch(k)   

if(ch=='y')   

}  if(flag2) break; 

}  cout<>n; max=n+100; 

if(!n) break;  

srand(time(null)); 

for(i=0;i>ch; 

if(ch!='y'&&ch!='n') 

cout<<"輸入錯誤!請輸入y/n進行選擇: "; 

else 

break; 

}  if(ch=='y')   

}  system("cls"); 

if(flag1) break; 

}  return 0; 

}  老師要求我把每個排序的每趟輸出的顯示出來,自己解決了一下發現會把功能2和功能3都顯示出來,誰來解決一下這個問題  

要求是顯示每趟的輸出 但是二三功能都不變

重溫一下各種排序演算法

最近打算用一些併發的模型研究一下排序演算法.所以,我首先回顧了一下各種排序演算法,並將它們用c語言實現了.氣泡排序 基本思想 先取第乙個元素,將它與後面n 1個元素比較,將n個元素中最小的移到首部.接著,忽略第乙個元素,取第二個元素,將它與後面的n 2個元素比較,將n 1個 元素中最小的移到位置2....

簡單整理一下各種報錯。。。。。

通常來講,4開頭的就是前端的問題了,5開頭的就是後端的事 400 bad request 錯誤請求 401.1 logon failed 登入失敗 401.2 logon failed due to server configuration 由於伺服器配置,登入失敗 401.3 unauthoriz...

Enumerable Zip 實現一下

早上看到 geff zhang 介紹了enumerable zip,閒來沒事弄乙個實現。也談不上思路,看了張兄的測試 先寫了個簡單的結構 public static ienumerable zip this ienumerable first,ienumerable sencond,func fun...