Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用vb6求解线性方程组_Vb6 - Fatal编程技术网

用vb6求解线性方程组

用vb6求解线性方程组,vb6,Vb6,我必须找出方程ax+by=c的积分解,这样所有变量都大于0,(x+y)的值最小。我有C++实现。在vb6中需要它吗 void compute0(int &x,int &y,int a,int b,int c) // naive { int xx,yy; xx = -1; yy = -1; for (y = 0;;y++) { x = c - b*y; if (x < 0) break; // y out of

我必须找出方程ax+by=c的积分解,这样所有变量都大于0,(x+y)的值最小。我有C++实现。在vb6中需要它吗

void compute0(int &x,int &y,int a,int b,int c) // naive
{
    int xx,yy;
    xx = -1; yy = -1;
    for (y = 0;;y++)
    {
        x = c - b*y;
        if (x < 0) break; // y out of range stop
        if (x % a) continue; // non integer solution
        x /= a; // remember minimal solution
        if ((xx < 0) || (x + y <= xx + yy))
        { 
            xx=x; yy=y; 
        } 
    }
    x=xx; y=yy;
}
void compute0(int&x,int&y,int a,int b,int c)//天真
{
int xx,yy;
xx=-1;yy=-1;
对于(y=0;y++)
{
x=c-b*y;
如果(x<0)中断;//y超出范围停止
如果(x%a)继续;//非整数解
x/=a;//记住最小解

如果((xx<0)| |(x+y这应该对你有用

Private Sub compute0(x As Long, y As Long, ByVal a As Long, ByVal b As Long, ByVal c As Long) 'naive
Dim xx          As Long
Dim yy          As Long
Dim continue    As Boolean

xx = -1
yy = -1
y = 0
continue = True

Do While continue
    x = c - b * y
    If (x < 0) Then 'y out of range stop
        Exit Do
    End If

    If (x Mod a) = 0 Then
        x = x / a 'remember minimal solution
        If ((xx < 0) Or (x + y <= xx + yy)) Then
            xx = x
            yy = y
        End If
    End If
    y = y + 1
Loop

x = xx
y = yy
End Sub
Private Sub compute0(x长,y长,ByVal a长,ByVal b长,ByVal c长)幼稚
暗淡的xx一样长
暗淡的yy一样长
Dim继续作为布尔值
xx=-1
yy=-1
y=0
继续=真
边做边继续
x=c-b*y
如果(x<0),则“y”超出范围停止
退出Do
如果结束
如果(x Mod a)=0,则
x=x/a‘记住最小解

如果((xx<0)或(X+Y)你理解C++代码吗?在代码中没有什么特别的东西。查找如何在VB6中编写循环和进行基本的数学运算!…StAcExoad不是代码编写服务。你应该显示你目前为止所尝试的东西。看我不理解C++,特别是它的operators@martha别担心,我只是我有一个想法,在最初的答案中,我把变量作为整数,我刚刚编辑了它,所以它们是长的。确保VB6代码将它们作为长的。