作者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