I'm a little forgetful of programming and I have a mathematical algorithm to do, it's the transport problem, I'm in the northwest corner phase.
My question is a compilation error.
Code:
#include<iostream>
#include<conio.h>
using namespace std;
int minimo(int valor1,int valor2)
{
if(valor1<valor2)return valor1;
else return valor2;
}
int main()
{
int n,m,i,j;
cin>>n>>m;
int matriz[n][m];
for(i=0;i<n-1;i++)for(j=0;j<m-1;j++)cin>>matriz[i][j];
i=0;
j=0;
int x,y;
x=n-1;
y=m-1;
while( ((i<=m-2)&&(i<=n-2)) && ((j<=m-2)&&(j<=n-2)) )
do
{ matriz[i][j]=minimo(matriz[x,j],matriz[i,y]);
if(matriz[i][j]==matriz[x,j]){matriz[x,j]=0;matriz[i,y]-=matriz[i][j];}
if(matriz[i][j]==matriz[i,y]){matriz[i,y]=0;matriz[x,j]-=matriz[i][j];}
if(matriz[x,j]==0)i++;
if(matriz[i,y]==0)j++;}
return 0;
}
The error is this:
C:\Users\acer\Desktop\transporte.cpp||In function 'int main()':| C:\Users\acer\Desktop\transporte.cpp|28|error: invalid conversion from 'int (*)[(((sizetype)(((ssizetype)m) + -1)) + 1)]' to 'int' [-fpermissive]| C:\Users\acer\Desktop\transporte.cpp|5|error: initializing argument 1 of 'int minimo(int, int)' [-fpermissive]| C:\Users\acer\Desktop\transporte.cpp|28|error: invalid conversion from 'int (*)[(((sizetype)(((ssizetype)m) + -1)) + 1)]' to 'int' [-fpermissive]| C:\Users\acer\Desktop\transporte.cpp|5|error: initializing argument 2 of 'int minimo(int, int)' [-fpermissive]| C:\Users\acer\Desktop\transporte.cpp|29|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]| C:\Users\acer\Desktop\transporte.cpp|29|error: incompatible types in assignment of 'int' to 'int [(((sizetype)(((ssizetype)m) + -1)) + 1)]'| C:\Users\acer\Desktop\transporte.cpp|29|error: incompatible types in assignment of 'int' to 'int [(((sizetype)(((ssizetype)m) + -1)) + 1)]'| C:\Users\acer\Desktop\transporte.cpp|30|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]| C:\Users\acer\Desktop\transporte.cpp|30|error: incompatible types in assignment of 'int' to 'int [(((sizetype)(((ssizetype)m) + -1)) + 1)]'| C:\Users\acer\Desktop\transporte.cpp|30|error: incompatible types in assignment of 'int' to 'int [(((sizetype)(((ssizetype)m) + -1)) + 1)]'| C:\Users\acer\Desktop\transporte.cpp|39|error: expected 'while' before numeric constant| C:\Users\acer\Desktop\transporte.cpp|39|error: expected '(' before numeric constant| C:\Users\acer\Desktop\transporte.cpp|39|error: expected ')' before ';' token| ||=== Build failed: 13 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|