04 2020 档案
摘要:题 例题5-8 Unix is 命令(Unix is,UVA 400)。完整题目见参考[1] #include <iostream> #include <string> #include <algorithm> using namespace std; const int maxcol = 60;
阅读全文
摘要:正文 点运算符 . 例如 item.isbn() 只用于类类型对象。左侧运算对象必须是一个类类型的对象。右侧必须是该类型对象的一个成员名。运算结果是右侧对象指定的成员。 箭头运算符号 -> 例如 (*it).empty(); 是先对it解引用,然后解引用的的结果再执行点运算符。 箭头运算符是对上述表
阅读全文
摘要:例子 书上的原始代码: #include <iostream> using namespace std; struct Point { int x, y; Point(int x = 0, int y = 0): x(x), y(y) { // x(x), y(y) 等价于 // this->x =
阅读全文
摘要:例子 #include <cstdlib> #include <ctime> #include <vector> #include <algorithm> #include <cassert> using namespace std; void fill_random_int(vector<int>
阅读全文
摘要:例子 #include <iostream> #include <queue> #include <vector> using namespace std; struct cmp { bool operator() (const int a, const int b) const { return
阅读全文
摘要:题 例题5-6 团队队列(Team Queue,UVA - 540)。完整题目见参考[1] #include <cstdio> #include <queue> #include <map> using namespace std; const int MAXT = 1000 + 10; int m
阅读全文
摘要:题 集合栈计算机,完整题目见参考[1] 书上的原始代码如下: #include <iostream> #include <vector> #include <map> #include <set> #include <string> #include <stack> #include <algori
阅读全文
摘要:题 完整题目见参考[1]。 #include <iostream> #include <cstdio> using namespace std; int main() { int T, n, num; // 数据组数,商品种数,种商品的数量 float price, sum; // 某种商品的价格,
阅读全文
摘要:题 例题5-3 反片语(Ananagrams, UVa 156)完整题目见参考[1] 思路:首先把未标准化的单词逐个存到一个vector中,在存的过程中,将标准化后的单词,例如RIDE标准化后是deir,通过map存储并统计其出现的次数。然后根据map中所存储的信息进一步从第一个vector中筛选出
阅读全文
摘要:题&例子 vector的拷贝 #include <cstdio> #include <string> #include <vector> #include <iostream> using namespace std; void print(string lable, vector<int> &v)
阅读全文
摘要:题 例题5-2 木块问题。要区分onto和over,onto是要a与b直接接触,over则不需要。以及,move某木块时,要把它上面的木块全部归位,而pile某木块则不需要。 #include <cstdio> #include <string> #include <vector> #include
阅读全文
摘要:题&例子 例题5-1 大理石在哪儿 #include <cstdio> #include <algorithm> using namespace std; const int maxn = 10000; int main() { int n, q, x, a[maxn], kase = 0; whi
阅读全文
摘要:例子 #include<cstdio> #include<stack> using namespace std; int main() { stack<int> my_stack; printf("my_stack.empty(): %d\n", my_stack.empty()); // prin
阅读全文