2014/11/13

[C++] string大小寫轉換 (透過transform)

以前做大小寫轉換時候,會用tolower()、toupper()來做 (或者直接利用ASCII來加減)
比較麻煩的是要寫一個迴圈,一次一個字元來轉
剛剛有學弟問字串轉換的問題,順便google了一下,發現用transform只要一行就好
記得要#include <algorithm>


2014/11/02

Visual C++ 各種字串之間的轉換方法

Reference:
http://www.cnblogs.com/oomusou/archive/2008/07/24/cpp_string_net_string.html

要將C++ STL string轉成Visual C++的^String
可以透過gcnew()的參數來進行初始化

ex:

string data = "Hello World";
String ^str = gcnew String(data.c_str());

注意gcnew的參數需要是C-Style string,所以透過.c_str()做轉換

2014/10/26

[LTspice] Triangle Wave

LTspice doesn't have the  "Triangle Wave" option, so we use "PULSE" option to generate triangle wave. See the link below for more details.

Reference:
http://ltwiki.org/?title=LTspice_has_a_built_in_Triangle_Wave

Example:
Generate a triangle wave with low level 6V and high level 10V. Frequency= 1kHz


2014/10/18

[LTspice] 模擬 Operation Amplifier 元件

點選工具列上的Component按鈕


輸入需要的op amp model
這邊以LT1001為例,點選之後按OK,就能在畫面擺放所選的op amp


也能在輸入的地方打 opamp
LTspice會切到C:\Program Files (x86)\LTC\LTspiceIV\lib\sym\Opamps底下
就能看到所有的op amp model了

2014/09/06

POJ 1915 Knight Moves

Description
Background
Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?
The Problem
Your task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from another, so that you have the chance to be faster than Somurolov.
For people not familiar with chess, the possible knight moves are shown in Figure 1.