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

正文內(nèi)容

線性數(shù)學(xué)試題解答-資料下載頁

2024-10-04 15:59本頁面
  

【正文】 ements[0]。 //假設(shè)elements[0]是最小值,繼續(xù)找最小值 int minindex = 0。 for ( int i = 1。 i = top。 i++ ) if ( elements[i] min ) { min = elements[i]。 minindex = i。 } elements[minindex] = elements[top]。 //用最后一個(gè)元素填補(bǔ)要取走的最小值元素 top。 returnamp。 min。 //返回最小元素的值 }415 試?yán)脙?yōu)先級隊(duì)列實(shí)現(xiàn)棧和隊(duì)列?!窘獯稹? template class Type class PQueue。 //前視的類定義 template class Type class PQueueNode { //優(yōu)先級隊(duì)列結(jié)點(diǎn)類的定義 friend class PQueueType。 //PQueue類作為友元類定義 public: PQueueNode ( Typeamp。 value, int newpriority, PQueueType * next ) : data ( value ), priority ( newpriority ), link ( next ) { } //構(gòu)造函數(shù) virtual Type GetData ( ) { return data。 } //取得結(jié)點(diǎn)數(shù)據(jù) virtual int GetPriority ( ) { return priority。 } //取得結(jié)點(diǎn)優(yōu)先級 virtual PQueueNodeType * GetLink ( ) { return link。 } //取得下一結(jié)點(diǎn)地址 virtual void SetData ( Typeamp。 value ) { data = value。 } //修改結(jié)點(diǎn)數(shù)據(jù) virtual void SetPriority ( int newpriority ) { priority = newpriority。 } //修改結(jié)點(diǎn)優(yōu)先級 virtual void SetLink ( PQueueNodeType * next ) { link = next。 } //修改指向下一結(jié)點(diǎn)的指針 private: Type data。 //數(shù)據(jù) int priority。 //優(yōu)先級 ListNodeType *link。 //鏈指針 }。 template class Type class PQueue { //優(yōu)先級隊(duì)列的類定義 public: PQueue ( ) : front ( NULL ), rear ( NULL ) { } //構(gòu)造函數(shù) virtual ~PQueue ( ) { MakeEmpty ( )。 } //析構(gòu)函數(shù) virtual void Insert ( Typeamp。 value, int newpriority )。 //插入新元素value到隊(duì)尾 virtual Type Remove ( )。 //刪除隊(duì)頭元素并返回 virtual Type Get ( )。 //讀取隊(duì)頭元素的值 virtual void MakeEmpty ( )。 //置空隊(duì)列 virtual int IsEmpty ( ) { return front == NULL。 } //判隊(duì)列空否 private: PQueueNodeType *front, *rear。 //隊(duì)頭指針, 隊(duì)尾指針 }。templateclass Type void PQueueType :: MakeEmpty ( ) { //將優(yōu)先級隊(duì)列置空 PQueueNodeType *q。 while ( front != NULL ) //鏈不空時(shí), 刪去鏈中所有結(jié)點(diǎn) { q = front。 front = frontlink。 delete q。 } //循鏈逐個(gè)刪除 rear = NULL。 //隊(duì)尾指針置空 }templateclass Type void PQueueType :: Insert ( Typeamp。 value, int newpriority ) { //插入函數(shù) PQueueNodeType *q = new PQueueNode ( value, newpriority, NULL )。 if ( IsEmpty ( ) ) front = rear = q。 //隊(duì)列空時(shí)新結(jié)點(diǎn)為第一個(gè)結(jié)點(diǎn) else { PQueueNodeType *p = front, *pr = NULL。 //尋找q的插入位置 while ( p != NULL amp。amp。 ppriority = newpriority ) //隊(duì)列中按優(yōu)先級從大到小鏈接 { pr = p。 p = plink。 } if ( pr == NULL ) { qlink = front。 front = q。 } //插入在隊(duì)頭位置 else { qlink = p。 prlink = q。 //插入在隊(duì)列中部或尾部 if ( pr == rear ) rear = q。 } } templateclass Type Type PQueueType :: Remove ( ) { //刪除隊(duì)頭元素并返回 if ( IsEmpty ( ) ) return NULL。 PQueueNodeType *q = front。 front = frontlink。 //將隊(duì)頭結(jié)點(diǎn)從鏈中摘下 Type amp。retvalue = qdata。 delete q。 if ( front == NULL ) rear = NULL。 returnamp。 retvalue。 }templateclass Type Type PQueueType :: Get ( ) { //讀取隊(duì)頭元素的值 if ( IsEmpty ( ) ) return NULL。 else return frontdata。 } (1) 棧的定義與實(shí)現(xiàn) template class Type class Stack : public PQueue { //棧類定義 public: Stack ( ) : front ( NULL ), rear ( NULL ) { } //構(gòu)造函數(shù) void Insert ( Type amp。 value )。 //插入新元素value到隊(duì)尾 }templateclass Type void StackType :: Insert ( Typeamp。 value ) { //插入函數(shù) PQueueNodeType * q = new PQueueNode ( value, 0, NULL )。 if ( IsEmpty ( ) ) front = rear = q。 //棧空時(shí)新結(jié)點(diǎn)為第一個(gè)結(jié)點(diǎn) else { qlink = front。 front = q。 } //插入在前端 } (2) 隊(duì)列的定義與實(shí)現(xiàn) template class Type class Queue : public PQueue { //隊(duì)列類定義 public: Queue ( ) : front ( NULL ), rear ( NULL ) { } //構(gòu)造函數(shù) void Insert ( Typeamp。 value )。 //插入新元素value到隊(duì)尾 }templateclass Type void QueueType :: Insert ( Type amp。 value ) { //插入函數(shù) PQueueNodeType* q = new PQueueNode ( value, 0, NULL )。 if ( IsEmpty ( ) ) front = rear = q。 //隊(duì)列空時(shí)新結(jié)點(diǎn)為第一個(gè)結(jié)點(diǎn) else rear = rearlink = q。 //插入在隊(duì)尾位置 }
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1