0

I have the code below to translate to vb, I'm wondering what those bracket means. What's the difference between int cost[N][N] and bool S[N]

#define N 55             //max number of vertices in one part
#define INF 100000000    //just infinity

int cost[N][N];          //cost matrix
int n, max_match;        //n workers and n jobs 
int lx[N], ly[N];        //labels of X and Y parts
3
  • 1
    Damn. If I win this week's lottery jackpot, I'll have inifinitely many pennies!
    – us2012
    Oct 5, 2013 at 18:00
  • Dim cost(N-1, N-1) As Integer Oct 5, 2013 at 18:04
  • @us2012 It's true if you store it in half-precision float.
    – this
    Oct 5, 2013 at 18:04

2 Answers 2

1

What's the difference between int cost[N][N] and bool S[N] ?

They are two different type of arrays.
cost[N][N] is two dimensional integer array of size NxN while bool[N] is one dimentional boolean array of size N.

visual basic conversion

int cost[N][N]; ==> Dim cost(N-1,N-1) As Integer
int s[N];       ==> Dim s(N-1) As Integer

See VB tutorial

3
  • 1
    This question has two parts. You answered only one :)
    – haccks
    Oct 5, 2013 at 18:16
  • What is the second question?
    – Sohaib
    Oct 5, 2013 at 18:17
  • @SohaibI; What is int cost[N] in visual basic?
    – haccks
    Oct 5, 2013 at 18:22
1

The answer to your first question is:

cost[N][N] is a two dimension array on the other hand bool S[N] is a one dimensional array. Now what are dimensional arrays you could read from here:

http://en.wikipedia.org/wiki/Array_data_structure#One-dimensional_arrays

As to your second question

int cost[N][N];

is equivalent to:

Dim cost(N-1, N-1) As Integer

in VB

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.