第五章主要講了函式
#include
#include
#include
#include
using
namespace
std;
void test_5_9()
}std::cout
<< "母音字母個數為:\t"
<< cnt << endl;
}void test_5_10()
}std::cout
<< "母音字母a的個數為:\t"
<< cnt_a << endl;
std::cout
<< "母音字母e的個數為:\t"
<< cnt_e << endl;
std::cout
<< "母音字母i的個數為:\t"
<< cnt_i << endl;
std::cout
<< "母音字母o的個數為:\t"
<< cnt_o << endl;
std::cout
<< "母音字母u的個數為:\t"
<< cnt_u << endl;
std::cout
<< "空格的個數為:\t"
<< cnt_space << endl;
std::cout
<< "製表符的個數為:\t"
<< cnt_t << endl;
std::cout
<< "換行符的個數為:\t"
<< cnt_n << endl;
}void test_5_12() }}
std::cout
<< "ff個數為:\t"
<< cnt_f<< endl;
std::cout
<< "fl個數為:\t"
<< cnt_l << endl;
std::cout
<< "fi個數為:\t"
<< cnt_i << endl;
}void test_5_14()
else
str1 = str2;
cnt = 1;}}
if (cnt > max_cnt)
cout
<< max_str << "連續出現了"
<< max_cnt << "次"
<< endl;
}void test_5_17() ;
vector
b = ;
vector
duan = a.size() < b.size() ? a : b;
vector
chang = a.size() > b.size() ? a : b;
decltype(duan.size()) i = 0;
cout
<< duan.size() << endl;
cout
<< chang.size() << endl;
for (; i < duan.size(); i++)
if (i == duan.size())
else
}void test_5_19() while (cin);
}void test_5_20()
else
}if (flag == 0)
}void test_5_25()
catch (runtime_error err)
}}int main()
C Primer 第五版習題1 2
練習1.3 include using namespace std int main cout hello,world 練習1.4 include using namespace std int main cout enter two number cin a b cout the product ...
《C Primer第五版》習題5 17
開始寫時有乙個問題就是,如何同時將兩個輸入流送入兩個不同的vector中。查閱了相關的部落格發現是有兩個流物件成員 cin.clear 重置輸入流 cin.ignore 忽略最後乙個輸入字元 include include include using namespace std intmain ci...
C primer 第五版)第1章習題答案
初學c primer,記錄整理,使用ubuntu14.04和gnu編譯器,答案參考於github 第一章 開始 1.1 檔案命名約定 參考這裡 gcc 5.4 標頭檔案字尾 h,hh,hpp,h,tcc for shared template code 原始檔字尾 cp,cpp,cpp,c,cc,c...