Accelerated C 習題解答 第6章

2021-06-20 17:01:40 字數 2496 閱讀 5528

部分解答參考了網上已有解答

ex.6-1

#include #include #include #include #include using namespace std;

string::size_type width(constvector& v)

vectorframe(constvector& v)

ret.push_back(border);

return ret;}

vectorhcat(constvector& left,constvector& right)

s += string(width1- s.size(), ' ');

if (j != right.size())

ret.push_back(s);

}return ret;}

int main()

output =hcat(content, frame(content));

for (vector::const_iterator iter =output.begin(); iter != output.end(); ++iter)

getch();

return 0;

}

ex.6-2

#include #include #include #include #include #include using namespace std;

bool not_url_char(char c)

string::const_iterator url_end(string::const_iterator b,string::const_iterator e)

string::const_iterator url_beg(string::const_iterator b,string::const_iterator e)

i += sep.size();

}return e;}

vectorfind_urls(conststring& s)

}return ret;}

int main()

for (vector::const_iterator iter =lines.begin(); iter != lines.end(); ++iter)

}getch();

return 0;

}

ex.6-3

#include #include #include #include using namespace std;

int main()

ex.6-4

#include #include #include #include using namespace std;

int main()

ex.6-5

#include #include #include #include #include #include #include "student_info.h"

#include "grade.h"

#include "median.h"

using std::cin;

using std::cout;

using std::endl;

using std::domain_error;

using std::string;

using std::vector;

using std::back_inserter;

using std::remove_copy;

using std::max;

using std::streamsize;

using std::sort;

using std::setprecision;

//假設學生上交的家庭作業數量對他們的家庭作業成績並不會產生影響,對沒做家庭作業的學生用作為家庭作業的總成績

double optimistic_median(conststudent_info& s)

int main()

sort(students.begin(),students.end(), compare);

for (vector::size_type i = 0; i!= students.size(); ++i)

int main()

sort(students.begin(),students.end(), compare);

for (vector::size_type i = 0; i!= students.size(); ++i) {

cout <

Accelerated C 習題解答 第1章

ex.1 01 include include includeint main std cout std string name std cin name std cout include include includeint main std cout std string name std ci...

Accelerated C 習題解答 第3章

部分習題參考了網上已有的解答 ex.3 0 include include include include include include includeusing std cin using std cout using std endl using std string using std ve...

Accelerated C 習題 第0章

include using namespace std intmain this is a quote,and this is a backlash.include using namespace std intmain include using namespace std intmain inc...