C++

A collection of 20 posts

[UVa] 1103 - Ancient Messages

Problem Link: UVa 1103 - Ancient Messages Hint DFS, 數洞洞 Solution C++ #include <iostream> #include <vector> #include <algorithm> static constexpr int MAX = 200 + 2; static const int

[UVa] 572 - Oil Deposits

Problem Link: UVa 572 - Oil Deposits Hint DFS Solution C++ #include <iostream> static const int DIRECTIONS[][2] = {{-1, -1}, {0, -1}, {1, -1}, {-1, 0}, /*{0, 0},*/ {1, 0}, {-1,

[UVa] 13148 - A Giveaway

題目 Link: UVa 13148 - A Giveaway Hint 這題真的是 Giveaway... Code C++ #include <iostream> #include <vector> #include <algorithm> constexpr const int MAX = 100000000; int main() { std::vector&

[C++] 讀取整行 & 讀取整行的數字

讀取整行的內容 首先要確保有這兩個 header #include <string> #include <iostream> 用 std::getline() 來讀取整行, 第一個參數表示從哪裡讀入 (istream), 第二個參數表示輸出的地方 (string)。 std::string line; std::getline(std::cin, line); 完成! 完整的示範 #include <string>

[UVa] 699 - The Falling leaves

Problem Link: UVa 699 - The Falling leabes hint preorder Code C++ with array #include <iostream> bool recursion(); static constexpr const int MAX = 100; // less stack consumption static int pile[MAX]