C++ 没有与这些操作数匹配的运算符 #包括“stdafx.h” #包括 #包括 #包括 #包括 使用名称空间std; int_tmain(){ 双x1=5.25; 双y1=4.2345; int nx=10; int ny=11; 载体Bn(nx,ny); 向量x(nx); 向量y(ny); 对于(int i=0;i

C++ 没有与这些操作数匹配的运算符 #包括“stdafx.h” #包括 #包括 #包括 #包括 使用名称空间std; int_tmain(){ 双x1=5.25; 双y1=4.2345; int nx=10; int ny=11; 载体Bn(nx,ny); 向量x(nx); 向量y(ny); 对于(int i=0;i,c++,arrays,C++,Arrays,这里有多个问题: #include "stdafx.h" #include <iostream> #include <cmath> #include <array> #include <vector> using namespace std; int _tmain(){ double x1 = 5.25; double y1 = 4.2345; int nx = 10; int ny = 11; vector<doub

这里有多个问题:

#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <array>
#include <vector>

using namespace std;

int _tmain(){
  double x1 = 5.25;
  double y1 = 4.2345;
  int nx = 10;
  int ny = 11;
  vector<double> Bn(nx, ny);
  vector<float> x (nx);
  vector<float> y (ny);
  for (int i = 0; i <10; i++){
    for (float j = 0; j < 11; j++){
      Bn = exp((pow(x[nx]-x1,2)-pow(y[ny]-y1,2))
    } 
  }
  system ("pause");
  return 0;
}

for(int i=0;i这里有多个问题:

#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <array>
#include <vector>

using namespace std;

int _tmain(){
  double x1 = 5.25;
  double y1 = 4.2345;
  int nx = 10;
  int ny = 11;
  vector<double> Bn(nx, ny);
  vector<float> x (nx);
  vector<float> y (ny);
  for (int i = 0; i <10; i++){
    for (float j = 0; j < 11; j++){
      Bn = exp((pow(x[nx]-x1,2)-pow(y[ny]-y1,2))
    } 
  }
  system ("pause");
  return 0;
}

for(int i=0;i要填充
std::vector
请使用函数而不是赋值运算符。 受影响的行中还缺少

可能您想在
pow()
函数中使用循环indizes
i&j
,而不是常量10/11。我几乎猜不到您想做什么,于是想出了:

 for (int i = 0; i <10; i++){
    for (float j = 0; j < 11; j++){
      Bn = exp((pow(x[nx]-x1,2)-pow(y[ny]-y1,2))
    } 
  }
#包括
#包括
#包括
#包括
使用名称空间std;
int_tmain(){
双x1=5.25;
双y1=4.2345;
int nx=10;
int ny=11;
载体Bn(nx,ny);
向量x(nx);
向量y(ny);
/*todo:用值填充x和y*/

对于(int i=0;i要填充
std::vector
,请使用函数而不是赋值运算符。 受影响的行中还缺少

可能您想在
pow()
函数中使用循环indizes
i&j
,而不是常量10/11。我几乎猜不到您想做什么,于是想出了:

 for (int i = 0; i <10; i++){
    for (float j = 0; j < 11; j++){
      Bn = exp((pow(x[nx]-x1,2)-pow(y[ny]-y1,2))
    } 
  }
#包括
#包括
#包括
#包括
使用名称空间std;
int_tmain(){
双x1=5.25;
双y1=4.2345;
int nx=10;
int ny=11;
载体Bn(nx,ny);
向量x(nx);
向量y(ny);
/*todo:用值填充x和y*/

对于(int i=0;i将
exp
的结果赋给向量时,您希望发生什么?如果这是您的意图,那么这不是创建二维数据结构的正确方法。这是您的意图吗?否则您将如何编写数据数组???。我正在尝试创建二维数据结构。否则,您将如何创建二维数据结构二维数据结构??当将
exp
的结果分配给向量时,您希望发生什么?如果这是您的意图,那么这不是创建二维数据结构的正确方法。这是您的意图吗?否则您将如何编写数据数组???。我正在尝试创建二维数据结构。否则您将如何创建二维数据结构创建一个二维数据结构
另外,我很确定OP并不是要用
nx
类型的
double
元素初始化向量
Bn
,给它们所有的值
ny
。我不确定,他想做什么……这是我能猜到的最接近的。我制作了一个x和y的数组,然后计算Bn以产生一个结果数组。这些都不是wo数组需要有一个未知的大小。@user3087244您想使用哪些值来初始化两个向量x和y?我希望使用零值进行初始化。而且我很确定OP的意思不是要用
nx
类型的
double
元素初始化向量
ny
。I“我不确定,他想做什么……这是我能猜到的最接近的。我制作了一个x和y的数组,然后计算Bn以生成一个结果数组。这两个数组需要有一个未知的大小。@user3087244你想用哪个值初始化这两个向量x和y?我希望用零值初始化。