954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Matrix generation in C++

I have the following code:

for (int w=0; w<10; w++)
{
    //some lines of code
    unsigned long num = x.to_ulong(); 
    cout << "Decimal form is: " << num << endl;
}

Now what I want is, to make a matrix which will have these values of num, column wise. For example, matrix[i][j], where i is from, let's say "0 to 15", and "j" is from "0 to 15" as well. I want them to put like, matrix[0][0], then matrix[0][1], matrix[0][2] and so on, something like:

for(int i=0; i<=15; i++)
{
    for(int j=0; j<=15; j++)
        matrix[i][j] = num //here is problem, value of "num" what shall i write instead of it?
}
blessed87
Newbie Poster
2 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Your example doesn't seem to give enough information to answer this. Your first set of code has a loop using w, but the loop is not acting differently between iterations (probably something in your comment for "some lines of code.")

It seems that you would use the same value as what you had in first (x.to_ulong())

djarn
Newbie Poster
18 posts since Apr 2010
Reputation Points: 11
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: