原创 Huffman樹的實現

最近複習的時候遇見了哈夫曼編碼,雖然在數據結構和離散數學課上都見識到了這個編碼樹,不過今天時第一次動手寫哈夫曼樹,藉助了c++的stl寫起來還是比較簡單的。話不多說,現在開始。 1. 統計字符頻率 統計字符這個還是很簡單的,首先我

原创 PAT甲級1006. Sign In and Sign Out (25)

話不多說,代碼很簡單。 #include <cstdio> #include <cstring> using namespace std; int main(void) { char first[30], last[3

原创 PAT甲級1004CountingLeaves

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no

原创 PAT甲級1005. Spell It Right

b( ̄▽ ̄)d ,水題一道,沒有難度。 看原題: Given a non-negative integer N, your task is to compute the sum of all the digits of N, a

原创 Qt之QString

Ok,看一下Qt的Qstring。 1.QString的輸入。 這個就是常見的=賦值就行了。 例: QString str= "Hello"; 對於這個語句,輸入的是標準的C的”\0”結尾的字符串,Qt會將後面的字符串轉換成Un

原创 Leetcode 318 Maximum Product of Word Lengths

Leetcode 318 Maximum Product of Word Lengths 題目分析 Given a string array words, find the maximum value of length(word

原创 LeetCode 829. Consecutive Numbers Sum

LeetCode 829 Consecutive Numbers Sum 傳送門 題目分析 Given a positive integer N, how many ways can we write it as a sum of co

原创 PAT 1016. Phone Bills (25)

PAT 1016. Phone Bills (25) 題目分析 原題相信大家都看見了,題目幾乎不涉及算法,主要就是考大家的細心,題目大意就是給我們所有用戶的長途電話記錄,根據用戶分組,計算每個用戶需要交的電話費,打印賬單,這個題隱含着如果

原创 LeetCode 804 Unique Morse Code Words

LeetCode 804 Unique Morse Code Words 傳送門 題目分析 International Morse Code defines a standard encoding where each letter

原创 LeetCode 859 Buddy Strings

LeetCode 859 Buddy Strings 傳送門 題目分析 Given two strings A and B of lowercase letters, return true if and only if we can

原创 LeetCode 858 Mirror Reflection

LeetCode 858 Mirror Reflection 傳送門 題目分析 There is a special square room with mirrors on each of the four walls. Except

原创 LeetCode 842 Split Array into Fibonacci Sequence

LeetCode 842 Split Array into Fibonacci Sequence 傳送門 題目分析 Given a string S of digits, such as S = "123456579", we can

原创 LeetCode 567 Permutation in String

LeetCode 567 Permutation in String 傳送門 題目分析 Given two strings s1 and s2, write a function to return true if s2 contai

原创 LeetCode 853. Car Fleet

LeetCode 853. Car Fleet 傳送門 題目分析 N cars are going to the same destination along a one lane road. The destination is t

原创 計蒜客2018 第四場 A. 貝殼找房均價計算

貝殼找房每個月都會計算各個城市房價的均價,計算的最後一步爲: 將一個形如 X.YX.Y 的小數,用特殊近似法近似到整數。 計算完成後會將這個均價展示在首頁供用戶參考。 特殊近似法定義爲:從最右邊開始四捨五入到整數爲止。