如何调用具有 double& 的函数
How to call function having double&
我已通过以下代码阅读参数:
int row,col;
double A[maxm][maxn];
double B[maxn];
double N[maxn];
void read_file()
{
freopen("Dimen.txt","r",stdin);
scanf("%d",&row);
scanf("%d",&col);
freopen("A.txt","r",stdin);
for(int i=0;i<row;i++)
for(int j=0;j<col;j++)
scanf("%lf",&A[i][j]);
freopen("B.txt","r",stdin);
for(int i=0;i<row;i++)
scanf("%lf",&A[i][col]);
freopen("F.txt","r",stdin);
for(int i=0;i<row;i++)
scanf("%lf",&B[i]);
int value;
int value_F = simplex(row,col, A,B, value);
}
但是我在这一行中遇到了错误。
int value_F = simplex(row,col, A,B, value);
单纯形函数原型如下:
int simplex(int m, int n, double a[maxm][maxn], double b[maxn], double& ret)
如何调用函数 simplex ?方法是什么?
value
是 int
,但 simplex
想要引用 double
,而不是 int
。只需将 value
的类型更改为 double
即可。
而不是
int value;
int value_F = simplex(row,col, A,B, value);
使用
double value;
// ^^^ a double not an int
int value_F = simplex(row,col, A,B, value);
int
可以转换为 double
但不能转换为 double&
。
我已通过以下代码阅读参数:
int row,col;
double A[maxm][maxn];
double B[maxn];
double N[maxn];
void read_file()
{
freopen("Dimen.txt","r",stdin);
scanf("%d",&row);
scanf("%d",&col);
freopen("A.txt","r",stdin);
for(int i=0;i<row;i++)
for(int j=0;j<col;j++)
scanf("%lf",&A[i][j]);
freopen("B.txt","r",stdin);
for(int i=0;i<row;i++)
scanf("%lf",&A[i][col]);
freopen("F.txt","r",stdin);
for(int i=0;i<row;i++)
scanf("%lf",&B[i]);
int value;
int value_F = simplex(row,col, A,B, value);
}
但是我在这一行中遇到了错误。
int value_F = simplex(row,col, A,B, value);
单纯形函数原型如下:
int simplex(int m, int n, double a[maxm][maxn], double b[maxn], double& ret)
如何调用函数 simplex ?方法是什么?
value
是 int
,但 simplex
想要引用 double
,而不是 int
。只需将 value
的类型更改为 double
即可。
而不是
int value;
int value_F = simplex(row,col, A,B, value);
使用
double value;
// ^^^ a double not an int
int value_F = simplex(row,col, A,B, value);
int
可以转换为 double
但不能转换为 double&
。