91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

《The c++ programming language 》的習(xí)題答案

資源截圖

代碼片段和文件信息

/*?Code?for?exercise?10.12.
?|?
?|?“C++?Solutions--Companion?to?The?C++?Programming?Language?Third?Edition“
?|?by?David?Vandevoorde;?Addison-Wesley?1998;?ISBN?0-201-30965-3.
?|
?|?Permission?to?use?copy?modify?distribute?and?sell?this?software
?|?and?its?documentation?for?any?purpose?is?hereby?granted?without?fee.
?|?The?author?makes?no?representations?about?the?suitability?of?this
?|?software?for?any?purpose.??It?is?provided?“as?is“?without?express?or
?|?implied?warranty.
?‘----------------------------------------------------------------------*/

#include?
#include?

/*?The?following?can?go?in?a?header?file?*/

#include?
#include?

struct?Char_queue?{
???inline?Char_queue(unsigned?capacity?=?default_capacity);
???~Char_queue()?{?delete[]?queue_;?}
???bool?empty()?const?{?return?head_==tail_;?}
???inline?char?dequeue();
???inline?void?enqueue(char);
???bool?full()?const?{?return?head_==(tail_+1)%capacity_;?}
???static?bool?const?fixed_capacity?=?true;
private:
???static?unsigned?const?default_capacity?=?32;
???char?*queue_;
???unsigned?head_?tail_;
???unsigned?const?capacity_;
};

inline
Char_queue::Char_queue(unsigned?n)
???:?queue_(new?char[n+1])?head_(0)?tail_(0)?capacity_(n+1)?{
}

inline
char?Char_queue::dequeue()?{
???if?(!empty())?{
??????char?c?=?queue_[head_];
??????head_?=?(head_+1)%capacity_;
??????return?c;
???}?else
??????throw?std::underflow_error(std::string(“queue“));
}

inline
void?Char_queue::enqueue(char?c)?{
???if?(!full())?{
??????queue_[tail_]?=?c;
??????tail_?=?(tail_+1)%capacity_;
???}?else
??????throw?std::overflow_error(std::string(“queue“));
}

/*?Header?file?would?stop?here.?*/

/*?A?brief?test?of?the?above?implementation:?*/

int?main()?{
???Char_queue?q(4);
???while?(1)?{
??????if?(q.empty())?{?std::cout?<??????else?if?(q.full())?{?std::cout?<??????char?cmd?ch;
??????std::cin?>>?cmd;
??????try?{
?????????switch?(cmd)?{
?????????case?‘e‘:?case?‘E‘:
????????????std::cin?>>?ch;
????????????q.enqueue(ch);
????????????break;
?????????case?‘d‘:?case?‘D‘:
????????????std::cout?<????????????break;
?????????case?‘q‘:?case?‘Q‘:
????????????std::cout?<????????????return?0;
?????????default:
????????????std::cerr?<?????????}
??????}?catch?(std::exception?&x)?{
?????????std::cerr?<???????????????????<??????}
???}
???return?0;
}


?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??1998-09-22?16:14??Ch10\
?????文件????????2626??1998-09-06?19:29??Ch10\ex10_12a.cpp
?????文件????????1970??1998-09-06?19:30??Ch10\ex10_5.cpp
?????文件?????????807??1998-09-06?19:29??Ch10\ex10_15.cpp
?????文件????????2703??1998-09-06?19:30??Ch10\ex10_19.cpp
?????文件????????2890??1998-09-06?19:29??Ch10\ex10_12b.cpp
?????目錄???????????0??1998-09-22?16:14??Ch11\
?????文件????????1195??1998-09-06?19:32??Ch11\ex11_8.cpp
?????文件????????2263??1998-09-06?19:30??Ch11\ex11_1.cpp
?????文件?????????781??1998-09-06?19:31??Ch11\ex11_10.cpp
?????文件????????1624??1998-09-06?19:31??Ch11\ex11_4.cpp
?????文件????????5176??1998-09-06?19:43??Ch11\str.hpp
?????文件????????1014??1998-09-06?19:31??Ch11\ex11_21.cpp
?????目錄???????????0??1998-09-22?16:14??Ch12\
?????文件????????1072??1998-09-06?19:32??Ch12\ex12_1a.cpp
?????文件????????1031??1998-09-06?19:32??Ch12\ex12_1b.cpp
?????文件????????3139??1998-09-06?19:32??Ch12\ex12_10.cpp
?????文件????????1378??1998-09-06?19:32??Ch12\ex12_9.cpp
?????目錄???????????0??1998-09-22?16:14??Ch13\
?????文件?????????934??1998-09-06?19:33??Ch13\ex13_15.cpp
?????文件????????4753??1998-09-06?19:33??Ch13\ex13_2.cpp
?????目錄???????????0??1998-09-22?16:14??Ch14\
?????文件????????2046??1998-09-06?19:33??Ch14\ex14_1.cpp
?????文件????????3487??1998-09-06?19:33??Ch14\ex14_2.cpp
?????文件????????1627??1998-09-06?19:33??Ch14\ex14_10.cpp
?????目錄???????????0??1998-09-22?16:14??Ch15\
?????文件????????3041??1998-09-06?19:33??Ch15\ex15_2.cpp
?????目錄???????????0??1998-09-22?16:14??Ch15\Ex15_3\
?????文件?????????869??1998-09-06?19:46??Ch15\Ex15_3\Player.H
?????文件????????1365??1998-09-06?19:44??Ch15\Ex15_3\Board.H
?????文件????????2939??1998-09-06?19:44??Ch15\Ex15_3\Board.C
............此處省略111個(gè)文件信息

評(píng)論

共有 條評(píng)論