Essential C++ノート-第一章C++プログラミング基礎
Essential C++ノート-第一章C++プログラミング基礎
一、arrayとvector
二、書類の読み書き
三、演算子優先度
論理演算子NOT(!)算術演算子*,/,%算術演算子+,-比較演算子,<=,>=比較演算子=,!=論理演算子AND(&)論理演算子OR(|)コピー演算子=//上から下へ、優先度が下がる//同じ行の演算子が同じ優先度を持つ
一、arrayとvector
// vector +
#include
using namespace std;
vector<int> fibonacci, lucas, pell, triangular, square, pentagonal;
const int seq_cnt = 6;
// , seq_cnt
// vector
vector<int> *seq_addrs[seq_cnt] = {
&fibonacci, &lucas, &pell,
&triangular, &square, &pentagonal
};
// vector
vector<int> *current_vec = 0;
for (int ix = 0; ix < seq_cnt; ++ix) {
current_vec = seq_addrs[ix];
// 。。。
}
二、書類の読み書き
#include
// ofstream ,
// ,
// ,
ofstream outfile("seq_data.txt");
// ,
ofstream outfile("sqe_data.txt", ios_base:app);
//
if (!outfile) {
cerr << "open file error" << endl; // cerr
}
else {
outfile << "tets" << endl;
}
// ifstream ,
//
ifstream infile("seq_data.txt");
if (!infile) {
cerr << "open file error" << endl;
}
三、演算子優先度
論理演算子NOT(!)算術演算子*,/,%算術演算子+,-比較演算子,<=,>=比較演算子=,!=論理演算子AND(&)論理演算子OR(|)コピー演算子=//上から下へ、優先度が下がる//同じ行の演算子が同じ優先度を持つ