原创 UVA 272 TEX Quotes

#include <iostream> #include <cstdlib> #include <string> using namespace std; int main(int argc, char *argv[])

原创 Singleton Pattern (Java)

This article is part of Reference 1 and Reference 2. I just organize them in my own way. GOF definition Ensure

原创 ls和du顯示資料夾的size

本人學linux沒多久發現一件事情,使用ls和du顯示資料夾的size竟然不一樣,找了一些資料才懂,所以才決定發這篇文,剛學linux的人可以看一下,已經懂得高手就麻煩你們看一下,有錯請糾正。 基礎知識 ls - list the

原创 Program for Fibonacci numbers

本篇文章翻譯自 http://www.geeksforgeeks.org/program-for-nth-fibonacci-number/ 準備工作 首先先看一下Fibonacci numbers的定義 Fn=⎧⎩⎨⎪⎪0

原创 Lower case to upper case – An interesting fact

原文網址,並不是完全是原文的翻譯,而是瞭解之後,用自己的想法解釋一遍 Problem 有一個英文字串,請將這個字串變為大寫 Solution 一般我們的想法像這樣: char str[256] = "segmentfa

原创 A C Programming Language Puzzle

原文網址,本文不是完全翻譯,而是自己吸收過後,在寫下此筆記 Problem 有一變數a=12,b=36,請寫出一個c function/macro,回傳3612且不使用算數運算和字串處理的函式. Token-Pasting O

原创 Final Keyword In Java

Introduction final keyword can be used along with variables, methods and classes. - variable - method - c

原创 java Iterable and for each

Java api public interface Iterable<T> Implementing this interface allows an object to be the target of the “for-ea

原创 使用maven + eclipse 建置spark基礎環境

本篇有在windows,osx環境下測試過 本博客僅為作者筆記,還有很多細節沒提到 請各位見諒,歡迎批評指正 如需轉載,請附上本文網址 what is maven? Maven is a build automation to

原创 How to find size of array in C/C++ without using sizeof ?

原文網址,本文並不是完全翻譯,而是自己學習後的筆記 Introduction 當我們要算array長度時,我們可以使用sizeof,請參考以下代碼: int size = sizeof(arr)/sizeof(arr[0]);

原创 UVA 455 Periodic Strings

Problem https://uva.onlinejudge.org/external/4/455.pdf Thinking 使用窮舉法, 先測測看cycle=1合不合法在測2測3…測到跟字串一樣長為止, 若有重複的cycle取最小 S

原创 UVA 10340 All in All

Problem https://uva.onlinejudge.org/external/103/10340.pdf Thinking 其實只是在t字串裡有沒有s字串裡的所有字母, 且順序關係要和s一樣 比如說: 1. t = abc

原创 vim + syntastic + verilator or iverilog

若文章有錯誤請留言指證 需要轉載請通知筆者 Introduction syntastic讓你可以在vim裡可以使用lint功能,讓你在寫code時檢查看看有沒有語法上的錯誤或者可能潛在的錯誤 Install linter 首先

原创 ITSA [C_ST42-易] 子字串出現次數

Problem http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?a=1376 Thinking 使用 KMP algo 去算匹配成功的次數, 至於KMP algo是什

原创 UVA 1585 Score

Problem https://uva.onlinejudge.org/external/15/1585.pdf Thinking 這題遇到連續O則會開始加總一個會慢慢遞增的數字, 此數字再遇到X時變回1, 此題很簡單, 會記錄此題的原因