2019-06-20から1日間の記事一覧

[カーブフィット]express vi / 共振回路の周波数特性

Resonant_Circuit.vi - Google ドライブ p.464のproblem 4 ある共振回路の周波数特性が下のように取得されたとする。 周波数f(Hz) 電圧利得G 1500 0.07 1600 0.084 1700 0.102 1800 0.128 1900 0.168 2000 0.235 2100 0.374 2200 0.74 2300 0.861 2400 0.442…

STLの各種アルゴリズムを試してみる

参考: スラスラわかるC++ 第2版, pp.397-404 <algorithm>をインクルードする。 sort()、find()、count()、reverse()、replace()を試してみる。 #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ // 適当に可変長排列を宣言しておく。 vector <int> arr = {1,</int></algorithm></vector></iostream></algorithm>…

stackコンテナ / LIFO (後入れ先出し)タイプのデータ格納方式

<stack>をインクルードする。 #include <iostream> #include <stack> using namespace std; int main() { stack <int> st; // intを格納するスタックを変数stとして宣言する。 for (int i = 0; i < 5; i++) { st.push(i); // .push()でスタックに値を格納する。 } while (!st.empty()) { c</int></stack></iostream></stack>…

queueコンテナ / FIFO (先入れ先出し)タイプのデータ格納方式

<queue>をインクルードする。 #include <iostream> #include <queue> using namespace std; int main(){ queue <int> qu; // intを格納するキューを変数quとして宣言する。 for (int i = 0; i < 5; i++) { qu.push(i); // .push()でキューに値を格納する。 } while (!qu.empty()) { cout <</int></queue></iostream></queue>…

mapコンテナ / 聯想排列

<map>をインクルードする。 #include <iostream> #include <map> using namespace std; int main() { map <char, int> dict; // 聯想排列dictを宣言する。 int val = 0; for (char key = 'A'; key < 'F'; key++) { dict.insert(make_pair(key, val)); // make_pair()でキーと値とのペアを作</char,></map></iostream></map>…

vectorコンテナ / 可変長排列

<vector>をインクルードする。 #include <iostream> #include <vector> using namespace std; int main(){ vector <int> arr; // 可変長排列arrを宣言する。 arr = {0,1,2}; for (int i = 0; i < arr.size(); i++) { // .size()で要素の数が取得できる。 cout << arr[i] << ","; } cout << e</int></vector></iostream></vector>…

クラステンプレートを使ってクラスを定義する

#include <iostream> using namespace std; template <class dtype1, class dtype2> class Sute { private: dtype1 a; dtype2 b; public: Sute(dtype1 a, dtype2 b) { // コンストラクタ this->a = a; this->b = b; } dtype2 conv() { return (dtype2)this->a; } }; int main(){ Sute <int, char> test1(65, '1</int,></class></iostream>…