From f9a0ee28a428d5947bf5f3c07a33b659b3e133b8 Mon Sep 17 00:00:00 2001 From: guyueshui Date: Tue, 16 Apr 2019 21:54:07 +0800 Subject: [PATCH] reorgnize answers to cxxprimer's exercises --- .gitignore | 2 + CoordiTransform.cpp | 148 ++++++++++++++++++ NB.py | 16 ++ Unit/Unit.h | 33 ++++ Unit/Unit.hpp | 138 ++++++++++++++++ Unit/test.cpp | 20 +++ a.out | Bin 67960 -> 0 bytes card.cpp | 10 ++ cash.cpp | 38 +++++ chuan.cpp | 26 +++ cxx | Bin 13840 -> 0 bytes dancing.cpp | 55 +++++++ draft.cpp | 67 ++++++++ jd.cpp | 39 +++++ matdance.cpp | 54 +++++++ new_start/a.out | Bin 9120 -> 31728 bytes new_start/cxxprimer/8/cxxprimer-ex-8.1.cpp | 15 ++ new_start/cxxprimer/8/cxxprimer-ex-8.10.cpp | 38 +++++ new_start/cxxprimer/8/cxxprimer-ex-8.11.cpp | 63 ++++++++ new_start/cxxprimer/8/cxxprimer-ex-8.13.cpp | 43 +++++ new_start/cxxprimer/8/cxxprimer-ex-8.2.cpp | 6 + new_start/cxxprimer/8/cxxprimer-ex-8.3.cpp | 7 + new_start/cxxprimer/8/cxxprimer-ex-8.4.cpp | 27 ++++ new_start/cxxprimer/8/cxxprimer-ex-8.5.cpp | 27 ++++ new_start/cxxprimer/8/cxxprimer-ex-8.6.cpp | 26 +++ new_start/cxxprimer/8/cxxprimer-ex-8.7.cpp | 27 ++++ new_start/cxxprimer/8/cxxprimer-ex-8.8.cpp | 27 ++++ new_start/cxxprimer/8/cxxprimer-ex-8.9.cpp | 23 +++ new_start/{ => cxxprimer}/PersonInfo.txt | 0 new_start/cxxprimer/Sales_data.h | 61 ++++++++ new_start/cxxprimer/Sales_data.ipp | 40 +++++ new_start/cxxprimer/haha.res | 6 + new_start/cxxprimer/sale.log | 10 ++ new_start/{ => cxxprimer}/tt.txt | 0 .../data_structures/arrayList/arrayList.tcc | 2 +- new_start/ex8_11.cpp | 4 +- new_start/run | Bin 31848 -> 0 bytes numbers.cpp | 54 +++++++ numsq.cpp | 26 +++ pocker.cpp | 32 ++++ primality.cpp | 43 +++++ run | Bin 21960 -> 0 bytes spiralMatrix.cpp | 116 ++++++++++++++ zifu.cpp | 53 +++++++ 44 files changed, 1419 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 CoordiTransform.cpp create mode 100644 NB.py create mode 100644 Unit/Unit.h create mode 100644 Unit/Unit.hpp create mode 100644 Unit/test.cpp delete mode 100755 a.out create mode 100644 card.cpp create mode 100644 cash.cpp create mode 100644 chuan.cpp delete mode 100644 cxx create mode 100644 dancing.cpp create mode 100644 draft.cpp create mode 100644 jd.cpp create mode 100644 matdance.cpp mode change 100644 => 100755 new_start/a.out create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.1.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.10.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.11.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.13.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.2.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.3.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.4.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.5.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.6.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.7.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.8.cpp create mode 100644 new_start/cxxprimer/8/cxxprimer-ex-8.9.cpp rename new_start/{ => cxxprimer}/PersonInfo.txt (100%) create mode 100644 new_start/cxxprimer/Sales_data.h create mode 100644 new_start/cxxprimer/Sales_data.ipp create mode 100644 new_start/cxxprimer/haha.res create mode 100644 new_start/cxxprimer/sale.log rename new_start/{ => cxxprimer}/tt.txt (100%) delete mode 100644 new_start/run create mode 100644 numbers.cpp create mode 100644 numsq.cpp create mode 100644 pocker.cpp create mode 100644 primality.cpp delete mode 100755 run create mode 100644 spiralMatrix.cpp create mode 100644 zifu.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7456c47 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +JianZhiOffer/ +/**/a.out diff --git a/CoordiTransform.cpp b/CoordiTransform.cpp new file mode 100644 index 0000000..69b967a --- /dev/null +++ b/CoordiTransform.cpp @@ -0,0 +1,148 @@ +#include +#include +#include + +using namespace std; + +class Unit { +private: + using pos = unsigned int; + // using ctype = string; + pos rowIdx; + pos colIdx; + + //--- utilities ---// + // get row/col index from a R23C55 type + void getIdx_RC(string&); + // get index from a BC23 type + void getIdx_NRC(string&); + + // map from char to nums + char map[26] = {'A','B','C','D','E','F','G', + 'H','I','J','K','L','M','N', + 'O','P','Q','R','S','T', + 'U','V','W','X','Y','Z'}; + // return a num for the given char + pos alph2num(char _c) { + pos idx = 0; + for (; idx !=26; ++idx) { + if (map[idx] == _c) { + return idx + 1; + } + } + cerr << "letter not found!" << endl; + return 0; + } + + // return a char for the give num + char num2alph(pos _p) { return map[_p - 1]; } + + // return the corresponding string + string pos2letter(pos _p) { + if (_p <= 26){ + char c[1] = {num2alph(_p)}; + string s(c); + return s; + } + string res; + pos r = 0; + while (_p > 26) { + r = _p%26; + res += num2alph(r); + _p /= 26; + } + res += num2alph(_p); + std::reverse(res.begin(), res.end()); + // cout << "res: " << res << endl; + return res; + } + + // return the corresponding num + pos letter2pos(string& _s) { + auto len = _s.size(); + pos res = 0; + for (; len != 0; --len) { + res = res*26 + alph2num(_s[_s.size() - len]); + // cout << "res: " << res << endl; + } + return res; + } + +public: + // constructor1 + Unit(pos _r, pos _c) : rowIdx(_r), colIdx(_c) {} + + // constructor2 + Unit(string _a, bool _isRC) { + if (_isRC) { + getIdx_RC(_a); // R23C55 type + } else { + getIdx_NRC(_a); // BC23 type + } + } + + // selectors + pos getRow(void) { return rowIdx; } + pos getCol() { return colIdx; } + void convertor(bool); // coordinate convertor +}; + +// implemention +void Unit::getIdx_RC(string& _s) { + string::size_type c_pos = 0; + for (; c_pos!=_s.size(); ++c_pos) { + if (_s[c_pos] == 'C') break; + } + auto s1 = _s.substr(1, c_pos-1); + auto s2 = _s.substr(c_pos+1, _s.size()); + // cout << s1 << '\n' + // << s2 << endl; + rowIdx = std::stoi(s1); + colIdx = std::stoi(s2); +} + +void Unit::getIdx_NRC(string& _s) { + //rowIdx = std::stoi(_s); + string::size_type n_pos = 0; + for (; n_pos != _s.size(); ++n_pos) { + if (_s[n_pos] == '0' + || _s[n_pos] == '1' + || _s[n_pos] == '2' + || _s[n_pos] == '3' + || _s[n_pos] == '4' + || _s[n_pos] == '5' + || _s[n_pos] == '6' + || _s[n_pos] == '7' + || _s[n_pos] == '8' + || _s[n_pos] == '9' + ) break; + } + auto s1 = _s.substr(0, n_pos); + auto s2 = _s.substr(n_pos, _s.size()); + rowIdx = std::stoi(s2); + colIdx = letter2pos(s1); + // cout << "s1: " << s1 << '\n' + // << "s2: " << s2 << endl; +} + +// convertor +void Unit::convertor(bool _isRC) { + if (_isRC) { + cout << pos2letter(colIdx) + + std::to_string(rowIdx) << endl; + } else { + cout << "R" + + std::to_string(rowIdx) + + "C" + + std::to_string(colIdx) << endl; + } +} + +int main(){ + Unit u1(2, 3); + Unit u2("R23C55", true); + u2.convertor(1); + Unit u3("BC23", false); + u3.convertor(0); + return 0; +} diff --git a/NB.py b/NB.py new file mode 100644 index 0000000..7b40975 --- /dev/null +++ b/NB.py @@ -0,0 +1,16 @@ +import numpy as np + +def read_input(): + N = input() + N = int(N) + line = input().split() + Y = [int(_) for _ in line] + data = [] + + for _ in range(N): + line = input().split() + sz = line.size() + for x in line: + data.append(int(x)) + + mat = np.matrix(data, (N, sz)) diff --git a/Unit/Unit.h b/Unit/Unit.h new file mode 100644 index 0000000..0b278e6 --- /dev/null +++ b/Unit/Unit.h @@ -0,0 +1,33 @@ +#ifndef _UNIT_H_ +#define _UNIT_H_ + +#include + +class Unit { +private: + using pos = unsigned int; // type alias + pos rowIdx; + pos colIdx; + bool isRC; // is the type `R23C55` + void getIdx_RC(std::string); // build index for type 'R23C55' + void getIdx_NRC(std::string); // for type 'BC23' + +public: + // constructor1 + Unit(pos _r, pos _c) : rowIdx(_r), colIdx(_c) { } + // constructor2 + Unit(std::string); + + // selectors + pos getRow() { return rowIdx; } + pos getCol() { return colIdx; } + + // modifiers + void setRow(pos _r) { rowIdx = _r; } + void setCol(pos _c) { colIdx = _c; } + + // utilties + void printer(void); + void convertor(void); +}; +#endif diff --git a/Unit/Unit.hpp b/Unit/Unit.hpp new file mode 100644 index 0000000..e4e5d31 --- /dev/null +++ b/Unit/Unit.hpp @@ -0,0 +1,138 @@ +#include "Unit.h" +#include +#include + +// global map for quick search +char MAP[26] = {'A','B','C','D','E','F','G', + 'H','I','J','K','L','M','N', + 'O','P','Q','R','S','T', + 'U','V','W','X','Y','Z'}; + +// return a num for the given char +int alph2num(char _c) { + int idx = 0; + for (; idx != 26; ++idx) { + if (MAP[idx] == _c) + return idx + 1; + } + std::cerr << _c << "Not found!" << std::endl; + return 0; +} + +// return a char for the given num +char num2alph(int _i) { return MAP[_i - 1]; } + +void Unit::printer() { + std::cout << "row index: " << rowIdx + << "\ncol index: " << colIdx << std::endl; +} + +// declare function +bool typeInfer(std::string); +Unit::Unit(std::string _s) { + /* + * wishful thinking: i wish there is some function + * that helps me do the job + * e.g. + * - typeInfer() + * - getIdx_RC() + * - getIdx_NRC() + */ + isRC = typeInfer(_s); // set private isRC + if (isRC) { + getIdx_RC(_s); + } else { + getIdx_NRC(_s); + } +} + +bool typeInfer(std::string _s) { // infer the representation type + if (_s[0] == 'R' && std::isdigit(_s[1])) + return true; + else + return false; +} + +void Unit::getIdx_RC(std::string _s) { + /* + * build the row/col index for + * type 'R23C55' + */ + _s.erase(0, 1); // remove first 'R' + + // find where 'C' is + std::string::size_type c_pos = 0; + for (; c_pos != _s.size(); ++c_pos) { + if (_s[c_pos] == 'C') break; + } + auto s1 = _s.substr(0, 0 + c_pos); // s1 = "23" + auto s2 = _s.substr(c_pos + 1, _s.size()); // s2 = "55" + // set index + rowIdx = std::stoi(s1); + colIdx = std::stoi(s2); +} + +// how can I use Unit::pos here +int letter2pos(const std::string&); +void Unit::getIdx_NRC(std::string _s) { + /* + * build the row/col index for + * type 'BC23' + */ + + // find the first num + std::string::size_type n_pos = 0; + for (; n_pos != _s.size(); ++n_pos) { + if (std::isdigit(_s[n_pos])) + break; + } + + auto s1 = _s.substr(0, n_pos); // s1 should be "BC" + auto s2 = _s.substr(n_pos, _s.size()); // s2 should be "23" + rowIdx = std::stoi(s2); + colIdx = letter2pos(s1); +} + +int letter2pos(const std::string& _s) { + auto len = _s.size(); + int res = 0; + for (; len != 0; --len) { + res = res*26 + alph2num(_s[_s.size() - len]); + // std::cout << "res: " << res << std::endl; + } + return res; +} + + +// return the corresponding string +std::string pos2letter(int _p) { + if (_p <= 26){ + char c[1] = {num2alph(_p)}; + std::string s(c); + return s; + } + + std::string res; + int r = 0; + while (_p > 26) { + r = _p%26; + res += num2alph(r); + _p /= 26; + } + res += num2alph(_p); + std::reverse(res.begin(), res.end()); + // cout << "res: " << res << endl; + return res; +} + +void Unit::convertor() { + if (isRC) { + std::cout << pos2letter(colIdx) + + std::to_string(rowIdx) << std::endl; + } else { + std::cout << "R" + + std::to_string(rowIdx) + + "C" + + std::to_string(colIdx) << std::endl; + } +} diff --git a/Unit/test.cpp b/Unit/test.cpp new file mode 100644 index 0000000..9008534 --- /dev/null +++ b/Unit/test.cpp @@ -0,0 +1,20 @@ +#include "Unit.hpp" +#include + +using namespace std; + +int main() { + Unit u1(3, 4); + u1.printer(); + u1.setRow(33); + u1.setCol(44); + u1.printer(); + + Unit u2("R99C123"); + u2.printer(); + Unit u3("ABF417"); + u3.printer(); + u2.convertor(); + u3.convertor(); + return 0; +} diff --git a/a.out b/a.out deleted file mode 100755 index 12a7da64b8d0ead8089cead3821a59dc2f764ccf..0000000000000000000000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z9RqK zGO-}c!G0Bn`1yBNaZoe0w^0`(Fg}HrS3x(y}Tk-r8GB6Oh zj`^!RUwF;AgEWax|Jh$H$lye{0e_qEN4_IpN%KTq1d4M9PHW_zv;6+5{Cu(3rSh*d N1W}7GY6V1>?!PiTjz9na diff --git a/card.cpp b/card.cpp new file mode 100644 index 0000000..b451683 --- /dev/null +++ b/card.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +using namespace std; + +int opt() { + if (arr.size() == 2) return sum(arr); + +} diff --git a/cash.cpp b/cash.cpp new file mode 100644 index 0000000..17c425d --- /dev/null +++ b/cash.cpp @@ -0,0 +1,38 @@ +#include +#include + +using namespace std; + +class Cash { +public: + int m; + int n; + vector koc; + + Cash(int _m, int _n) : m(_m), n(_n) { } + + int func(int m, int n) { + if (m == 0) return 1; + else if (m < 0 || n == -1) return 0; + else + return func(m, n-1) + + func(m - koc[n-1], n); + } +}; + + +int main(){ + int m, n; + cin >> m >> n; + + Cash cc(m, n); + + for (int i=0; i!=n; ++i) { + int tmp; + cin >> tmp; + cc.koc.push_back(tmp); + } + + cout << cc.func(m, n); + +} diff --git a/chuan.cpp b/chuan.cpp new file mode 100644 index 0000000..06ec6e9 --- /dev/null +++ b/chuan.cpp @@ -0,0 +1,26 @@ +#include +#include + +using namespace std; + +void cancel(string& _s) { + if (_s.size() < 2) return; + int idx = 0; + for (; idx != _s.size()-1; ) { + if (_s[idx] != _s[++idx]) { + _s.erase(--idx, 2); + break; + } + } + cancel(_s); +} + +int main() { + int n = 0; + string str; + cin >> n; + cin >> str; + cancel(str); + cout << str.length(); + return 0; +} diff --git a/cxx b/cxx deleted file mode 100644 index 40831b174ef63dd23a78a9a8646ca39d1ee8039e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13840 zcmeHOeQ;FO6~CKJNaSM^kkkNL9x5G>vSdSmP>NhL?TQh!PG#(LWSrVEZD+)OU^{kb1P67d(}8};Otod4>Lgk#EtH`a+5XOb_iWyN zS;vn5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pc5 z-eHm4!n_>0{FxN)#8AKK?*TRA7VYC&IEqBZ0pX6u%#a(YY0FLj4#n+=Cfz;BFp_S= zLE$E@&!6ZM?%+@q_AF|~t(INLI1hE^gVSWgbgLxUq@% zV`H{IMLv0*&MWXJ#&1ij@OvOrKCe*CQkLsPufrd`y0d<_sxZ~iW-oZGWfc!NyS}OP znO>hIO~0|TOEcIDI5Xh>`TdhA>+^X6|2|_Y?WoWz1nZBf3ez(b9282JqAKh2dB?55 z@Dn7Xe^5Edl+S4(B8xJ|thfs`Iuqgk`MsCv5+%w0vmDc%Xs0t4=J}k3>3*e8{*#~V zzk*M z&7c1i8tnS~{?7C;D=NybLrfpf(dXaUOq(cZw!(T0J&B6Fe?AXj%I9M&ua*b1;-J#! z`182|)BiR8Lpl0t zVLj%{p-dS2&+mJ~tWU;mMYGkZIuq?AQk#Rbetizk=IoT$zFqX^n#H}M&V}hYM9&KL opT|Y_7yE8$Sl8ht7QK+O;JIIxosCK%{awo~2|7oymmF677e%Bs*8l(j diff --git a/dancing.cpp b/dancing.cpp new file mode 100644 index 0000000..59d201e --- /dev/null +++ b/dancing.cpp @@ -0,0 +1,55 @@ +#include +#include + +using namespace std; + +int main() { + int n = 0, m = 0; + cin >> n >> m; + int t = m + n; // total number + vector > ans(t, vector(t, 0)); + + // build ans matrix + int x = 0; + for (int i = 0; i != n; ++i) { + int cnt = 0; + cin >> cnt; + for (int k = 0; k != cnt; ++k) { + cin >> x; + ans[i][n + x] = 1; + } + } + for (int i = n; i != t; ++i) { + int cnt = 0; + cin >> cnt; + for (int k = 0; k != cnt; ++k) { + cin >> x; + ans[i][x] = 1; + } + } + // End of building ans + + int songs = 0; + for (int i = 0; i != t; ++i) { + int temp = 0; + int up_line = 0; + int j = 0; + + if (i < n) { + j = n; + up_line = t; + } else { + j = 0; + up_line = n; + } + + for (; j != up_line; ++j) { + if (ans[i][j] == 1) ++temp; + else if (ans[j][i] == 1) ++temp; + } + + songs = songs < temp? temp : songs; + } + cout << songs << endl; + return 0; +} diff --git a/draft.cpp b/draft.cpp new file mode 100644 index 0000000..1e2b135 --- /dev/null +++ b/draft.cpp @@ -0,0 +1,67 @@ +// #include +// +// void fun(char* t, char* s) { +// while (*t != '\0') +// t++; +// while ((*t++=*s++) != '\0'); +// } +// +// int main() { +// char s1[10] = "123", s2[10] = "9978"; +// fun(s1, s2); +// printf(s1); +// return 0; +// } + +#include +#include +#include +#include + +using namespace std; + +class Solution {}; + +int numSee(const vector& soldierArray, int numSoldier) { + if (numSoldier == 0) return 0; + int curMax = soldierArray[0]; + int cnt = 1; + for (int i=1; i curMax) { + curMax = soldierArray[i]; + ++cnt; + } + } + return cnt; +} + +void f(double n) { + cout << "==>" << n << endl; +} +// entrance +int main(){ + /* + int numCols; + vector soldierArray; + vector res; + cout << "input numCols: \n"; + cin >> numCols; + for (int i=0; i!=numCols; ++i) { + int tmp = 0; + int numSoldier = 0; + cout << "input numSoldier: \n"; + cin >> numSoldier; + while (cin >> tmp) { + soldierArray.push_back(tmp); + } + res.push_back(numSee(soldierArray, numSoldier)); + } + + for (auto &c : res) { + cout << c << endl; + } + */ + double a = pow(2, 3); + f(a); + return 0; +} diff --git a/jd.cpp b/jd.cpp new file mode 100644 index 0000000..b4780de --- /dev/null +++ b/jd.cpp @@ -0,0 +1,39 @@ +#include +#include +#include + +using namespace std; + +int maxone(const string& s, + string::iterator beg, + string::iterator end) { + // boundary cases + if (beg >= end) return 0; + + auto pos1 = std::find(beg, end, "10"); + if (pos1 == end) + return static_cast(end - beg); + + auto pos2 = std::find(pos1, end, "01"); + if (pos2 == end) { + return static_cast(pos1 - beg); + } else { + ++pos2; + return max( + static_cast(pos1 - beg), + maxone(s, pos2, end) + ); + } +} + +int main() { + string s; + cin >> s; + while (s[0] == '1' && s.back() == '1') { + s.insert(0, "1"); + s.pop_back(); + } + int maxlen = maxone(s, s.begin(), s.end()); + cout << maxlen; + return 0; +} diff --git a/matdance.cpp b/matdance.cpp new file mode 100644 index 0000000..d6b1aca --- /dev/null +++ b/matdance.cpp @@ -0,0 +1,54 @@ +#include +#include +#include + +using namespace std; + + +class Pos { +public: + int x; + int y; +}; + +class Mat { +public: + vector ones; + vector twos; + vector > table; + + void read_input() { + int var; + while (cin >> var) { + table.push_back(vector()); + } + } + + int steps(int i, int j) { + int d_border = table.size() - 1; + int r_border = table[0].size() - 1; + + for (auto iter = twos.begin(); + iter != twos.end(); + ++iter) { + int i = iter -> x, + j = iter -> y; + build_IJ + + } + } + + void printer() { + for (auto &r : table) { + for (auto &c : r) + cout << c << ' '; + cout << endl; + } + } +}; + +int main() { + Mat m; + m.read_input(); + return 0; +} diff --git a/new_start/a.out b/new_start/a.out old mode 100644 new mode 100755 index 34db3b3b31b01afcb555375de0f6ad5e5dfa1608..e84a1c61a90175ac8a6c08ecc15110d72bac8696 GIT binary patch literal 31728 zcmeHw4|H3_mG_hXBrZ*CLlf5gDN)kE1~?Ix<0LjDU^`ZLCJu4^2hu=zQDiw*u`O4U zgF_RVV#uOR&E|AdnwA#4+rm=1+ooSBb@?cD{%p*4yEL@<+AIa?Wr39m3og(emj?9x z?#!L1d9svdUD5BH?_?6|zPb0#ojZ5#+?n?@Z}b^o$IP`P0) zH_YV}EMiC+UeTO?MjCWS)PKb+{aOl^gP|f%`=+0 zzHD~c#Punt`u&Qo(B@^8S9G;6?h5tv^)K$PTDEvur6(HpRETzyeB!i~OI%0W#@XnMKaQEOOq>(ys0-@^@w7U!R449@^{1 zUwYb=MbBedP|`9}HnhaLq78wT znAaQV^hc~%#2<sw;WEi2I9 z@AY~sBo~-MJzE-DDy^2KR;$UN`rN7_m4Mw8j9)DLTw$0jFF4go_$~J{MSab$6 z`Br&-r!qvK#cN4Z`pA@416sbWH`vo1Zb!esGTAJcp)M&06*jF2G_Pq{f==Ji-qi%7 zq7VGmW^{dz74XLbox*w*<(3uejD&Bqx`I7hVx3kn5(!68R!}R0J?&kY410<`Uxpe* zRVZs$G`%K3|4Pzdx(3=rt^o_dpQO&4{q2^&t1BGH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|H&haqIuqrO)?NrbA@h zQF#6t8b`&4hr`781^#~k?s&02)7PO}#<*dgDwq`_4yt>PEMgT$>01B>oa{HO-_Bm_aD{4|I+`+rO)5#O-i5rWDmGs z=08P+F!uj|>c2xN(%;>kCE#RG{~QmA)VXlhU+lu!oRjj}b&B?@{u@=kh0Yo3gZ=0C kpWYAl-Kl?4z4$M>8o6JVCI4I^vZ+TUR_VU&EG}032k-Ooh5!Hn diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.1.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.1.cpp new file mode 100644 index 0000000..60a6739 --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.1.cpp @@ -0,0 +1,15 @@ +#include +#include + +using namespace std; + +istream& rw(istream& istrm) { + auto old_state = istrm.rdstate(); + istrm.clear(); // ready to use + char e; + while (istrm >> e) { + cout << e; + } + istrm.setstate(old_state); + return istrm; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.10.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.10.cpp new file mode 100644 index 0000000..fff4b2a --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.10.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +using namespace std; + +// read a file by line, push them in a vector +vector read_file(string _fn) { + ifstream f(_fn); // open file + if(f) { // if stream is good + vector ret; + string line; + while (getline(f, line)) + ret.push_back(line); + + return ret; + } else { + cerr << "Cannnot open file: " + _fn + << endl; + return vector{"bad string"}; + } +} + +int main(int argc, const char* argv[]) { + vector svec = read_file(argv[1]); + string str; + + for (auto &e : svec) { + // read word using `stringstream` + istringstream iss(e); + while (iss >> str) { + cout << str << endl; + } + } + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.11.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.11.cpp new file mode 100644 index 0000000..83cc69d --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.11.cpp @@ -0,0 +1,63 @@ +#include +#include +#include + +using namespace std; + +struct PersonInfo { + string name; + vector phones; + + void printer() { + cout << "--> name: " << name << endl; + cout << "--> phones: "; + for (auto &e : phones) + cout << e << ' '; + cout << endl; + } +}; + +int main() { + string line, word; + vector people; + + /* + while (getline(cin ,line)) { + PersonInfo info; + istringstream record(line); + record >> info.name; + while (record >> word) + info.phones.push_back(word); + + people.push_back(info); + } + */ + + // if we put record outside + istringstream record; + while (getline(cin, line)) { + PersonInfo info; + record.str(line); // initialize stringstream + record >> info.name; + while (record >> word) + info.phones.push_back(word); + + people.push_back(info); + // cout< +#include +#include +#include + +using namespace std; + +struct PersonInfo { + string name; + vector phones; + + void printer() { + cout << "--> name: " << name << endl; + cout << "--> phones: "; + for (auto &e : phones) + cout << e << ' '; + cout << endl; + } +}; + +int main(int argc, const char* argv[]) { + vector people; + ifstream f(argv[1]); // open file + + if (f) { // stream `f` is good + string line, word; + while (getline(f, line)) { + PersonInfo info; + istringstream record(line); //bind to string stream + record >> info.name; + while (record >> word) + info.phones.push_back(word); + + people.push_back(info); + } + for (auto &e : people) + e.printer(); + } else + cerr << "Cannot open file: " + string(argv[1]) + << endl; + + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.2.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.2.cpp new file mode 100644 index 0000000..77d44ef --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.2.cpp @@ -0,0 +1,6 @@ +#include "cxxprimer-ex-8.1.cpp" + +int main(int argc, const char* argv[]) { + rw(cin); + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.3.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.3.cpp new file mode 100644 index 0000000..169ad80 --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.3.cpp @@ -0,0 +1,7 @@ +/* + * It will fail in one of the following: + * - strm.eof() + * - strm.fail() + * - strm.bad() + * or !strm.good() + */ diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.4.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.4.cpp new file mode 100644 index 0000000..a6378c3 --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.4.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +using namespace std; + +vector read_file(string filename) { + // create stream and initialized + ifstream f(filename, ifstream::in); + vector ret; + string line; + + while (getline(f, line)) // read line + ret.push_back(line); + + f.close(); // close file + return ret; +} + +int main(int argc, char* argv[]) { + vector svec = read_file(argv[1]); + + for (auto &c : svec) { + cout << c << endl; + } + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.5.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.5.cpp new file mode 100644 index 0000000..f746ba9 --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.5.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +using namespace std; + +vector read_file(string filename) { + // create stream and initialized + ifstream f(filename, ifstream::in); + vector ret; + string str; + + while (f >> str) // read word + ret.push_back(str); + + f.close(); // close file + return ret; +} + +int main(int argc, char* argv[]) { + vector svec = read_file(argv[1]); + + for (auto &c : svec) { + cout << c << endl; + } + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.6.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.6.cpp new file mode 100644 index 0000000..3d5c952 --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.6.cpp @@ -0,0 +1,26 @@ +#include "../Sales_data.ipp" +#include + +using namespace std; + +int main(int argc, char* argv[]) { + Sales_data total; + ifstream input(argv[1]); // open file + + if (read(input, total)) { + Sales_data trans; + while (read(input, trans)) { + if (total.isbn() == trans.isbn()) + total.combine(trans); + else { + // write to cout + print(cout, total) << endl; + total = trans; + } + } + print(cout, total) << endl; + } else + cerr << "No data?!" << endl; + + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.7.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.7.cpp new file mode 100644 index 0000000..19ad0e4 --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.7.cpp @@ -0,0 +1,27 @@ +#include "../Sales_data.ipp" +#include + +using namespace std; + +int main(int argc, char* argv[]) { + Sales_data total; + ifstream input(argv[1]); // open file + ofstream output(argv[2]); + + if (read(input, total)) { + Sales_data trans; + while (read(input, trans)) { + if (total.isbn() == trans.isbn()) + total.combine(trans); + else { + // write to local file + print(output, total) << endl; + total = trans; + } + } + print(output, total) << endl; + } else + cerr << "No data?!" << endl; + + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.8.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.8.cpp new file mode 100644 index 0000000..d7258ad --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.8.cpp @@ -0,0 +1,27 @@ +#include "../Sales_data.ipp" +#include + +using namespace std; + +int main(int argc, char* argv[]) { + Sales_data total; + ifstream input(argv[1]); // open file + ofstream output(argv[2], ofstream::app); // just one change here + + if (read(input, total)) { + Sales_data trans; + while (read(input, trans)) { + if (total.isbn() == trans.isbn()) + total.combine(trans); + else { + // write to local file + print(output, total) << endl; + total = trans; + } + } + print(output, total) << endl; + } else + cerr << "No data?!" << endl; + + return 0; +} diff --git a/new_start/cxxprimer/8/cxxprimer-ex-8.9.cpp b/new_start/cxxprimer/8/cxxprimer-ex-8.9.cpp new file mode 100644 index 0000000..dd14e6b --- /dev/null +++ b/new_start/cxxprimer/8/cxxprimer-ex-8.9.cpp @@ -0,0 +1,23 @@ +#include +#include + +using namespace std; + +istringstream& rw(istringstream& istrm) { + auto old_state = istrm.rdstate(); + // reset iostate will not affect + // the contents of a stream + istrm.clear(); + string e; + while (istrm >> e) + std::cout << e << endl; + + istrm.setstate(old_state); + return istrm; +} + +int main() { + istringstream is("you can do it!"); + rw(is); + return 0; +} diff --git a/new_start/PersonInfo.txt b/new_start/cxxprimer/PersonInfo.txt similarity index 100% rename from new_start/PersonInfo.txt rename to new_start/cxxprimer/PersonInfo.txt diff --git a/new_start/cxxprimer/Sales_data.h b/new_start/cxxprimer/Sales_data.h new file mode 100644 index 0000000..7c19878 --- /dev/null +++ b/new_start/cxxprimer/Sales_data.h @@ -0,0 +1,61 @@ +#ifndef _SALES_DATA_H_ +#define _SALES_DATA_H_ + +#include +#include + +class Sales_data { +private: + std::string bookNo; + unsigned units_sold = 0; + double revenue = 0.0; + +public: + // constructors + Sales_data() = default; + Sales_data(std::string a, unsigned b, double c) + : bookNo(a), units_sold(b), revenue(c) {} + + // cannot bind const to non-const + Sales_data(const Sales_data& a) + : bookNo(a.bookNo), + units_sold(a.units_sold), + revenue(a.revenue) {} + + Sales_data(std::string _bookNo) : Sales_data(_bookNo, 0, 0) {} + + // selectors + std::string isbn() const { return bookNo; } + unsigned get_sold() const { return units_sold; } + double get_revenue() const { return revenue; } + + // modifiers + Sales_data& set_bookNo(std::string a) { + bookNo = a; + return *this; + } + Sales_data& set_sold(unsigned a) { + units_sold = a; + return *this; + } + Sales_data& set_revenue(double a) { + revenue = a; + return *this; + } + + // sum datas for same books + Sales_data& combine(const Sales_data&); + double avg_price() const { + return units_sold? revenue / units_sold + : 0; + } +}; + +//--- non-interface ---// +// add two objects' sales' data +Sales_data add(const Sales_data&, const Sales_data&); +// read bookNo, units_sold, and price from a input stream +std::istream& read(std::istream&, Sales_data&); +std::ostream& print(std::ostream&, const Sales_data&); + +#endif // _SALES_DATA_H diff --git a/new_start/cxxprimer/Sales_data.ipp b/new_start/cxxprimer/Sales_data.ipp new file mode 100644 index 0000000..0c2f76f --- /dev/null +++ b/new_start/cxxprimer/Sales_data.ipp @@ -0,0 +1,40 @@ +/* + * Implemention of class `Sales_data` + */ + +#include "Sales_data.h" + +Sales_data& Sales_data::combine(const Sales_data& rhs) { + units_sold += rhs.units_sold; + revenue += rhs.revenue; + return *this; +} + +std::istream& read(std::istream& is, Sales_data& item) { + double price = 0.0; + unsigned sales = 0; + std::string book; + + is >> book >> sales >> price; +// std::cout << "what i read is: " +// << book << ' ' +// << sales << ' ' +// << price << std::endl; + item.set_bookNo(book). + set_sold(sales). + set_revenue(sales * price); + return is; +} + +std::ostream& print(std::ostream& os, const Sales_data& item) { + os << item.isbn() << ' ' + << item.get_sold() << ' ' + << item.get_revenue(); + return os; +} + +Sales_data add(const Sales_data& lhs, const Sales_data& rhs) { + Sales_data sum = lhs; // invoke copy constructor + sum.combine(rhs); + return sum; +} diff --git a/new_start/cxxprimer/haha.res b/new_start/cxxprimer/haha.res new file mode 100644 index 0000000..0df6122 --- /dev/null +++ b/new_start/cxxprimer/haha.res @@ -0,0 +1,6 @@ +Algorithm-Design 122 8043.2 +Block-Chain 62 4092 +Information-Theory 18 590.4 +Algorithm-Design 122 8043.2 +Block-Chain 62 4092 +Information-Theory 18 590.4 diff --git a/new_start/cxxprimer/sale.log b/new_start/cxxprimer/sale.log new file mode 100644 index 0000000..777e28f --- /dev/null +++ b/new_start/cxxprimer/sale.log @@ -0,0 +1,10 @@ +Algorithm-Design 19 70.0 +Algorithm-Design 19 70.0 +Algorithm-Design 20 68.8 +Algorithm-Design 20 68.8 +Algorithm-Design 22 59.8 +Algorithm-Design 22 59.8 +Block-Chain 31 66.0 +Block-Chain 31 66.0 +Information-Theory 9 32.8 +Information-Theory 9 32.8 diff --git a/new_start/tt.txt b/new_start/cxxprimer/tt.txt similarity index 100% rename from new_start/tt.txt rename to new_start/cxxprimer/tt.txt diff --git a/new_start/data_structures/arrayList/arrayList.tcc b/new_start/data_structures/arrayList/arrayList.tcc index 8d01d21..eea6ce6 100644 --- a/new_start/data_structures/arrayList/arrayList.tcc +++ b/new_start/data_structures/arrayList/arrayList.tcc @@ -1,5 +1,5 @@ /* - * the implementation of class arrayList + * The implemention of class arrayList */ #include "arrayList.h" diff --git a/new_start/ex8_11.cpp b/new_start/ex8_11.cpp index 9eb0604..a2d24b2 100644 --- a/new_start/ex8_11.cpp +++ b/new_start/ex8_11.cpp @@ -12,8 +12,8 @@ struct PersonInfo{ }; int main(int argc, char const *argv[]) { - string line,word; - std::vector people; + string line, word; + vector people; /*while(getline(cin,line)){ //book code PersonInfo info; diff --git a/new_start/run b/new_start/run deleted file mode 100644 index e427d2bd128eea3d1731f28ed2eaeae0ac2221d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31848 zcmeHwe|%NdmG8+9AR>mKs1c~dUxUd1%hD;^y2+y4?y~}nQlFN! zE6!QLRa$3R0c)mpu{9o;arh4~g`m39@T7>=Fi-e$0CVwQnXM3&*#W-LaE3x#8fpy* zQhja;$fbfqr7EkTWfd`k%8{;vH*ywm4PR(@Q1nQWVw{Tjlh9OdSjr7cISnl-r=e~i zwT=E8h2EGQK#uYO0#*%wx{!D&)xQ^y(sl1l&H@JbLc_S|r=c$Q7br)1jx`ks<8rCb z&n_jRzlORWu5E2;swlsHP`O^6{_x&9VxtOR@^Mdcse}|0RDs zan|hM8+B86Oj@*|_TCqO@=c^qQ3mR2;Lgo}-{XV-TWFApf1?lnO&>WyAO3tF{5Bu_ z0w4L0```zC@auf!M}@yr;sLUp$UWH(9{lx?GsT)_?F_78KGkEE6%zi99)1gc)E$pT zuD+Ulr^2%Bb!{E(c6U776}N56zGGQKyt1XE+inVX$I5HlTjDjP!S#&qXzdQxFJ9iz z(O?IuTyL-48SCoqXb-ox#5dUMOTZOvttaM&czLWn+FBcFh?kZ|n!{aoyer%i@2-sm zgUf-N2k9*lyQ4ea6$`i3HrkCPcCev>>IZd!ZO5CtI_`rGQ9In)+7VF-cobWt6l=e) zjf=H**N&~WNF(Z+Z`Uu0pd2;Vwxh9lxTUppzFpVS9k<&%qA_m&0(+_5+|hAwu)d*0 z=~f=;=!tVNvPKhGvrQQiSL-4XyPI;Qmc63=zLxf=y*$?4(-tGPh_-j6H*AOFvEG)r z)fQ`O>sTLyF^NGsp)K6fZr!qIkv*@t#JZ)fwtA6WR$Nv*-&(Y4RaJGZU0OU(p;xT} zOL=kWd^5{VfZ&*o(VoLFS70{cD&ey^o@ZgC-wxl=jl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Y?U)p?U-q^^I-t*X2^@D02dj@6da-%crqBIZZhY?ldua zv~*UMaE!D&%(1N7GX*6z>5&K7P1r+{Z8rpsO6`2L>}cd?YIn_0GJPheUiZx9{wr9Q z!n-2IdKQ|Fd8!RJ1Z&!9jN|4q!>XS&D(61*EN;`*7W0ga44)Z?grT3uun*wB38}Uk z5&f|nMVnE+`;|_3N*l4HhO-FgDNXwbb{aL>kmF@|tVU=oEk(D>6@gq~z0K=6tM_BKcup3BC53?q?!|Aq#=keAhFIwpa(`Qjmbh>F-q!#5dx}#Rz;wqD-CiM<&`Zjjz8>|lA zrONOtUV(t|LsS0Ib5UuAKv{a~s9+B2qSZ$GEBxZ0WBW{j)l9G6X-OF^B zSRhVUyPO{cVFzzHDlV<)iqS2--4&CkKeY%t!E$~Cr_Wno)bWKZ=@zN&6{YK|F4;m@1rcdU+?7D5o~*| z>*$iTv;Q-)1!*NH8jf{ctS5s}$6Z@6Wz<1Y?0P#JFL>-kTQ7chPi9Q_b3I;g(iotd z5bP{j#oZg);^8L1c$b3B`l_WJ&lfta;`WYstQbGKb`6ComBTaA;-;P!{19VH)GDT2 zbGW1Nf>}PE9bi&i%3sbo_rqJBzAuMkMmx0rJF)}Jyh9M>oO9oo z!`FRN(lX@mRZ~a*!R!EXIP+D?@0JFS2aYav`9fksT8aN0{OkJldrligQT_fM@lx{I z?{47e-8WrczYoe$hN0Bqj>-Q#hYrhvf<%cf~ zF#GVO46H}>7mrld=|9O@{kSme*YB}yk}n$Fr5ObhubF;<3{|1k)bI7^-`(}LSGv{F z<1Lh>@2=|d`n|ZJ8-Ya9{3_?>HU0w-NGDxhzdx5eO?fTvV_cB$>hk(MJN>)Jx?{C} z>w0y&PNJ+?zkVNY_-0ju=2N+J{r~7G@4UAcP$f3&f&z8@8jeThX8rp8zRgnJuYN6d z5(<+n-G2IwK1w?R46H&DZlogPnl7hE{Usi}E +#include +#include + +using namespace std; + +// const protection since I will never change +// arr in the whole process. +int opt(const vector& arr, + int beg, int end, bool isFront) { + // base cases + if (beg >= end) return 0; + if (end - beg == 1) { + if (isFront) + return abs(arr[beg] - arr[beg-1]); + else + return abs(arr[beg] - arr[end]); + } + + // ELSE + int front_gain = 0, + back_gain = 0; + + if (isFront) { + front_gain = abs(arr[beg] - arr[beg-1]); + back_gain = abs(arr[end-1] - arr[beg-1]); + } else { + front_gain = abs(arr[beg] - arr[end]); + back_gain = abs(arr[end-1] - arr[end]); + } + return max( + front_gain + opt(arr, beg+1, end, true), + back_gain + opt(arr, beg, end-1, false) + ); +} + + +int main(){ + int N = 0; + cin >> N; + vector arr; + for (int i=0; i!=N; ++i) { + int tmp; + cin >> tmp; + arr.push_back(tmp); + } + // for (auto c : arr) cout << c << ' '; + int maxwin = max( + opt(arr, 1, arr.size(), true), + opt(arr, 0, arr.size()-1, false) + ); + cout << maxwin; + return 0; +} diff --git a/numsq.cpp b/numsq.cpp new file mode 100644 index 0000000..1cc5849 --- /dev/null +++ b/numsq.cpp @@ -0,0 +1,26 @@ +#include + +using namespace std; + +int solver(int i, int j) { + if(i == j) return i+1; + else if (i < j) { + if (i+1 == j) { + return 2*(i+1); + } else { + return i+1 + solver(i, j-1); + } + } else { + if (j+1 == i) { + return 2*(j+1); + } else { + return j+1 + solver(i-1, j); + } + } +} + +int main(){ + int i = 0, j = 0; + cin >> i >> j; + cout << solver(i, j); +} diff --git a/pocker.cpp b/pocker.cpp new file mode 100644 index 0000000..1249f79 --- /dev/null +++ b/pocker.cpp @@ -0,0 +1,32 @@ +#include +#include + +using namespace std; + +queue pile; + +void solution(int n) { + // initialize queue + for (int i=0; i != n; ++i) + pile.push(i + 1); + + while (!pile.empty()) { + cout << pile.front() << ' '; + pile.pop(); + pile.push(pile.front()); + pile.pop(); + } +} + +int main() { + int num_test = 0; + int n = 0; + cin >> num_test; + + while (num_test--){ + cin >> n; + solution(n); + cout << '\n'; + } + return 0; +} diff --git a/primality.cpp b/primality.cpp new file mode 100644 index 0000000..3d2d8da --- /dev/null +++ b/primality.cpp @@ -0,0 +1,43 @@ +//#include +#include +#include + +using namespace std; + +auto square = [](int x) -> int { return x*x; }; +auto myremainder = [](int x, int y) -> int { + if (y == 0) return -1; + return x%y; +}; + +int expmod(int base, int power, int m) { + if (power == 0) return 1; + else if (power&1) + return myremainder(base * expmod(base, power-1, m), + m); + else + return myremainder(square(expmod(base, power>>1, m)), + m); +} + +// Fermat test +bool fermat_test(int n) { + return + [n](int a) -> bool { + return a == expmod(a, n, n); + } (std::experimental::fundamentals_v2::randint(1, n-1)); +} + +// fast prime test +bool fast_prime(int n, int times) { + if (times == 0) return true; + else if (fermat_test(n)) + return fast_prime(n, times-1); + else + return false; +} + + +int main(){ + cout << fast_prime(19999, 10); +} diff --git a/run b/run deleted file mode 100755 index aba41d46863ac692210401397bfb86c5b73b4ee4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21960 zcmeHPe{@vUoqw4m5`QI;LW@de7R7?fm`Oq!1nUGc@FEGMB%!GykIBr0%$m%^nF%CR zY&6z(8q-Z%v>r<>TGzwsp0jCBPh}~^2&|~v(?;8MQ0 zMB=g?wv|db1r^<_&nfAe4c>i$#4Bi(Bj4;A+#L${^)K$Ptyx@C?TSTQm7?9GpLkcVZ4)MuTUnK$&qA4S zM0Y;$!@A?2?z&=C>qp=D&bmVnZXJI2H^e&=f22dUt6by>M``v$7p;`J+`kE+6|a@! zvrstSir{=B@VWT!$)o2~9{jRAdiLeve=HBaE03O@JpAOGT=vfczY~ACyQs81xsQ!F0vUwbXZP>p67TY4g4BNq2Xg(tZN?LBpEo)oiwV_DN=hL-7G)YlUXq66kIQ?Ut6f`;&$d?}|pYK`vnUy1OHOB4jCBDU?B=JJtXx zx4+95HR4fUC?0F@d%f#{t3u5ozY&SWqd{L!gTK}Awk$FH&=%g-BPy%*NBZJId!#$& z4QX&hkMsd@Tl{__MkTjqw1u~Y!U1D_FxJ--BsRZt6};rX-SBtaZgl!W-DsY_-)H#Z z!Tt~wi$Z6J8oE8G^#pr*B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SE-w+HZ%0r!$X zsIwCvOaP-1ALtEwF=NsHcx4TSZ6MNP`27B0EM`WY9GpgL(@M3nGnf^_`vR; zmN>qDfO#<2ND;KYxLqW#ORHn}!hwn_HmBO*W2B6rm3E$n*iq_Lu<`;4wtXhdbLl~|HVV~+JkEfCgqKFeM1inFew zS^TJurW4yYTWsBI`(%!aWpRZ7caq=oe~p<7gWsM`&FTU z=Au%UFV>~G0s~>_lQ15Yl&$zs5T>n+f&p4I*zF?$&h>WVT9X1obK%oF_!Yt9iblj$ zf-Bg?m$qF2$f^>Q;uAl?et)nxjun``XC!pUt6r%?-m|n8Y*} zuD^S5O|5P^`~{G1gWwh%o(ajMp6e>ex1*SvejcR|be{pYEKT{ttVltpVq}Qh<{8P2 zl2!f~%PV+Q1~)x3%S`ns;&t$dvR}RLprDdh_l0mfGb61<3AegT`_*%21)nG9AmKK& z@RO3~+rrug;PL3glvmHE6;$t2fJG!$r;6GpNRdKW^K z)$?uz2e~G)pX^ljGg{k@4Ea>atLNehI@w@Vzmiw&znA4#utN2Ihk~aVPx5qY&@TTK z;HV0+PbBp`ogv?*Q`D^fPk>^Tce0#T7HI0SZ=m^EU(6?QlsQlc?N_Dr|chO`9UR5$}P!h z$y1ijP!Nl~ol2f>YnxI^ofWFsHJOmv%?hV@0MR;Bi9cn(Y8M^{nYJTqra^jv1L?aI bT$ZHjRVaGCquQ=;1l>)tG}|U%D{B7@9HO;% diff --git a/spiralMatrix.cpp b/spiralMatrix.cpp new file mode 100644 index 0000000..00df45f --- /dev/null +++ b/spiralMatrix.cpp @@ -0,0 +1,116 @@ +/* + * Build a Spiral matrix in clockwise order + * Microsoft 2019 interview + */ + +#include +#include +#include // for using setw() + +using namespace std; + +class Mat { +private: + int n; // nxn matrix + vector > mat; + // is current coordinate a border? + bool isBorder(const int, + const int); + +public: + // constructor + Mat(int _n) { + n = _n; + while (_n--) { + // for a temp object, use `vector()` + mat.push_back(vector(n, 0)); + } + } + ~Mat(void) = default; + void buildMat(void); + void printer(void); +}; + +/* + * Basic idea: + * 1. populate the matrix until a border is reached + * 2. once reach a border, change directions, + * the directions is given by [0,1,2,3] which + * represent [right, down, left, up] + * 3. until n^2 elements are all populated + * + * Note: populate from large to small + */ + +void Mat::buildMat() { + int n2 = n*n; + int i = 0, + j = 0, + direction = 0; + + while (n2) { + direction %= 4; // --> [0,1,2,3] + while (!isBorder(i,j)) { + if (direction == 0) { + mat[i][j++] = n2--; + if (isBorder(i,j)) { + j--; + i++; + break; + } + } + if (direction == 1) { + mat[i++][j] = n2--; + if (isBorder(i,j)) { + i--; + j--; + break; + } + } + if (direction == 2) { + mat[i][j--] = n2--; + if (isBorder(i,j)) { + j++; + i--; + break; + } + } + if (direction == 3) { + mat[i--][j] = n2--; + if (isBorder(i,j)) { + i++; + j++; + break; + } + } + } + ++direction; // change the direction + } +} + +bool Mat::isBorder(const int _i, + const int _j) { + if (_i == n + || _i == -1 + || _j == n + || _j == -1 + || mat[_i][_j] != 0) return true; + return false; +} + +void Mat::printer() { + for (auto &row : mat) { + for (auto &col : row) { + cout << setw(3) << col << ' '; + } + cout << endl; + } +} + +// entrance +int main() { + Mat m(4); + m.buildMat(); + m.printer(); + return 0; +} diff --git a/zifu.cpp b/zifu.cpp new file mode 100644 index 0000000..2d2ce67 --- /dev/null +++ b/zifu.cpp @@ -0,0 +1,53 @@ +/* + * 百度2019笔试题 + * 用KMP算法求循环节 + */ +#include +#include +#include + +using namespace std; + +unsigned int calDiff(string _s) { + auto len = _s.length(); + if (len <= 1) return 0; + + auto str = _s; + vector known = {_s}; + unsigned int cnt = 0; + + while (--len) { + // construct new str + str.push_back(_s[0]); + str.erase(0,1); + //cout << "_s: " << _s + // << "\nstr: " << str << endl; + + bool isKnown = false; + // find if already known + for (auto &c : known) { + if (c == str) { + isKnown = true; + break; + } + } + if (!isKnown) { + ++cnt; + // update known list + known.push_back(str); + } + _s = str; + } + if (cnt < 1) { + return 0; + } else { + return cnt + 1; + } +} + +int main(){ + string s; + cin >> s; + cout << calDiff(s) << endl; + return 0; +}