作者ric2k1 (Ric)
看板EE_DSnP
標題Re: [問題] 作業1.2的第二題
時間Sun Mar 16 01:24:52 2008
※ 引述《allencaliang (阿摩尼亞)》之銘言:
: 三個問題:
: 1. vector 型態是要自己用class來設對不對?
#include <vector>
or refer to
http://www.sgi.com/tech/stl/
http://www.sgi.com/tech/stl/table_of_contents.html
: 2. 第二題第二小題要求把 selectionSort() 函數的prototype改成:
: void selectionSort
: (vector<int>& array, const Compare& compare);
: 我在 Comapre& 前有 const 的時候編譯不給過,把const去掉之後就ok了
: 問問看如果沒const會不會扣分? (" ̄▽ ̄)>
Make sure when using Compare as an functional object, its "operator ()" is
a const method.
: 3. 第二題第三小題說:
: any data type as long as its "operator <" and "operator >" are defined
: 之後要分別做字串和double兩種type的排序
: 但是字串的大於小於運算子並不是去比較字串的第一個字的ASCII code大小
: 而是對字串的指標做比較
: 這樣和一般數字或是char的比較方式有差異
: 比出來好像就是先存在的字串較大,後宣告的字串較小
: 不知道樣板要怎麼處理這樣的問題?
#include <string>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.121.129.182