原创 Sample 5.1:forloop.cpp

#include<iostream> int main() { using namespace std; int i; for( i = 0;i < 5;i++) cout << "C++ know

原创 Sample 5.7:plus_one.cpp

#include<iostream> int main() { using namespace std; int a = 20; int b = 20; cout << "a = " << a << ";

原创 Sample 5.4: formore.cpp

#include<iostream> using namespace std; const int ArSize = 16; int main() { double factorials[ArSize]; factoria

原创 2.3-2

分治排序無哨兵位僞代碼: MERGE(A,p,q,r) n1 <- q-p+1 n2 <- r-q; create arrays L[1...n1] and R[1...n2] for i <- 1 to

原创 Sample 5.5: bigstep.cpp

#include<iostream> int main() { using namespace std; cout << "Enter an integer: "; int by; cin >> by;

原创 二進制數轉十進制數

C++代碼實現: #include<iostream> #include<fstream> #include<cmath> #include<string> using namespace std; int main() { if

原创 Exercise 5.1

#include<iostream> int main() { using namespace std; int m,n; cout << "請輸入較小的整數:"; cin >> m; cout <

原创 2.2-3 & 2.2-4

2.2-3 n/2個;n個;O(n) 解答:平均查找一般就能查出結果,前提是序列中有要查詢的元素。最壞情況就是沒有該元素出現在待查隊列中,要進行全部掃描,所以查n次,O(n)爲時間複雜度。 2.2-4 首先分析問題的要求,找出要解決問

原创 十進制數轉二進制數

C++代碼實現: #include<iostream> #include<fstream> #include<cmath> #include<string> #include<vector> using namespace std; i

原创 Sample 5.8: block.cpp

#include<iostream> int main() { using namespace std; cout << "The Amazing Accounto wii lsum and average ";

原创 分治排序(有哨兵位)

C++代碼: #include<climits> void MERG(int *A,int p,int q,int r){ int n = p - q + 1; int m = r - q; int L = ne

原创 Sample 5.2:num_test.cpp

#include<iostream> int main() { using namespace std; cout << "Enter the starting countdown value:"; int lim

原创 Sample 5.3:express.cpp

#include<iostream> using namespace std; int main() { int x; cout << "The expression x = 100 has the value ";

原创 2.3-4

C++代碼實現: MERGE(A,p,q,r) n1 <- q-p+1 n2 <- r-q; create arrays L[1...n1] and R[1...n2] for i <- 1 to n1

原创 Exercise 5.3

#include<iostream> int main() { using namespace std; double Daphne_rate = 0.1; double Cleo_rate = 0.05;