📄 testbintree.cpp
字号:
// tetbintree.cpp
//
// Creating a structure for the binomial tree
//
// (C) Datasim Education BV 2003
//
#include "vector.cpp"
#include "arraymechanisms.cpp"
int main()
{
int N = 2; // Number of periods
Vector<Vector<double, int>, int> tree(N+1, 1);
// Initialise tree vectors (give sizes of vectors)
for(int ii = tree.MaxIndex(); ii >= tree.MinIndex(); ii--)
{
tree[ii] = Vector<double, int>(ii);
}
for(int i = tree.MaxIndex(); i>= tree.MinIndex(); i--)
{
for(int j = 1;j <= i;j++)
{
tree[i][j] = i;
}
}
for(int k = tree.MaxIndex(); k >= tree.MinIndex(); k--)
{
print (tree[k]);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -