?? selecttm.cpp
字號(hào):
#ifndef SELECTTM_H
#define SELECTTM_H
#include "datalist.h"
template <class Type> void dataList <Type>::Swap (const int mark1, const int mark2) {
Type temp = Element[mark1];
Element [mark1] = Element [mark2];
Element [mark2] = temp;
}
template < class Type> void dataList <Type>::MaxKey(const int low, const int high) {
int max = low;
if ( k >= ArraySize ) k = ArraySize - 1;
for (int k = low+1, k <= high, k++)
if ( Element[max] < Element[k] ) max = k;
return max;
}
template <class Type> ostream& operator << (ostream& outStream, const dataList <Type> outList) {
outStream << "Array Contents:\n" ;
for (int i = 0; i < outList ; i++)
outStream << outList.Element[i] << ' ' ;
outStream << endl;
outStream << "Array Current Size:" << outList.ArraySize << endl;
return outStream;
}
template <class Type> istream& operator >> (istream& instream,dataList <Type> inList) {
cout << "Enter array Current Size:";
inStream >> inList.ArraySize;
cout << "Enter array elements:\n";
for (int i=0; i<inList.ArraySize; i++) {
cout << "Element" << i << ":" ;
inStream >> inList.Element[i];
}
return inStream;
}
template <class type> void dataList <type>::Sort() {
for (int i = ArraySize - 1; i > 0; i-- ) {
int j = MaxKey ( 0, i );
if ( j != i ) Swap ( j, i );
}
}
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -