C++网格阵列矢量ostream
C++ mesh array vector ostream
我在故障排除方面遇到了极大的困难,如果有任何建议,我将不胜感激。1.我正在尝试创建一个网格阵列。这应该会生成一个50、52、54、56…100的向量。在调试过程中,我从未看到矢量增加超过50。2.我正在尝试打印网格阵列。我不能在这里使用ostream,因为这不是一个类。所以即使我能让矢量工作,我也不知道如何打印它
#include <vector>
#include <iostream>
using namespace std;
vector<double> MeshArray(double start, double end, double h)
{
vector<double> mesh;
mesh.reserve(100);
for (double i = start; i <= end; i + h)
mesh.push_back(i);
return mesh;
}
int main()
{
vector<double> MA = MeshArray(50,100,2);
cout << MA;
return 0;
}
#include<iostream>
#include"Header.h"
#include<cstdlib>
using namespace std;
int main()
{
vector<double> MA = MeshArray(50, 100, 2);
int size = MA.size();
for (int i = 0; i < size; i++)
cout << MA[i] << endl;
system("Pause");
return 0;
}
#include<vector>
#include<iostream>
using namespace std;
vector<double> MeshArray(double start, double end, double h)
{
vector<double> mesh;
mesh.reserve(100);
for (double i = start; i <= end; i += h)
mesh.push_back(i);
return mesh;
}
相关文章:
- OpenMP阵列性能较差
- ostream过载时的缓冲区冲洗
- 如何将三维尺寸不固定的三维阵列展平为一维阵列
- 当我的阵列太大时出现分段错误
- 需要从 istream 和 ostream 派生 iostream
- 位阵列上的快速AND运算
- "ostream &os"有什么用?
- 阵列必须使用大括号封闭的初始器进行初始化
- 为什么常量词在重载运算符中不与 ostream 对象一起使用<<?
- 没有从阵列<float>到阵列<int>的可行转换
- C++动态安全 2D 交错阵列
- 将平面阵列重塑为复杂的特征类型
- 如何使用英特尔 PIN 捕获阵列的所有负载?
- 为什么我能够为阵列分配比计算机实际拥有的内存更多的内存
- 库特<<恩德尔;不适用于打印 2D 阵列
- 数组类 阵列的打印输出
- 从较小的阵列到较大的阵列的元素级转换
- 仅在大型阵列上出现合并排序分段错误
- 我的运算符重载是否有效<<(流插入)左操作数不是 ostream
- C++网格阵列矢量ostream