導讀 關(guān)于隨機排序函數(shù)表,隨機排序函數(shù)這個問題很多朋友還不知道,今天小六來為大家解答以上的問題,現(xiàn)在讓我們一起來看看吧!1、我有答案你要
關(guān)于隨機排序函數(shù)表,隨機排序函數(shù)這個問題很多朋友還不知道,今天小六來為大家解答以上的問題,現(xiàn)在讓我們一起來看看吧!
1、我有答案你要把#include?#include?#include?#define?LS(a,b)?((a)<(b))#define?LL(a,b)?((a)>(b))#define?MAXSIZE?1000typedef?int?KeyType;typedef?struct?{????int?key;}RedType;typedef?struct{????RedType?r[MAXSIZE+1];????int?length;}SqList;typedef?SqList?HeapType;int?compare=0;int?change=0;int?Create_Sq(SqList?&L){????int?i,k;????cout<<"請輸入產(chǎn)生隨機數(shù)的個數(shù):";????cin>>k;????L.length=k;????for(i=1;i<=k;++i)????{????????????????L.r[i].key=rand();????}????return?1;}void?Bubble_sort(SqList?&L){//冒泡排序????int?i,j,l,k=L.length;????for(i=1;i<=L.length-1;++i)????{??????????for(j=1;j<=k-1;++j)??????????{???????????????++compare;???????????????if(LL(L.r[j].key,L.r[j+1].key))???????????????{????????????????????l=L.r[j].key;????????????????????L.r[j].key=L.r[j+1].key;????????????????????L.r[j+1].key=l;????????????????????++change;????????????????}??????????}??????????--k;????}????cout<本文分享完畢,希望對大家有所幫助。
標簽:
免責聲明:本文由用戶上傳,如有侵權(quán)請聯(lián)系刪除!