Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3876448
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:22:58+00:00 2026-05-19T22:22:58+00:00

I have the following code: for (int w=0; w<10; w++) { //some lines of

  • 0

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?
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:22:59+00:00Added an answer on May 19, 2026 at 10:22 pm

    Here is some pseudo code..

    std::vector<std::vector<unsigned long> > matrix(15); // 15 rows
    typedef std::vector<std::vector<unsigned long> >::iterator it_type;
    
    it_type row = matrix.begin();
    
    for (int w=0;w<10;w++)
    {
      //some lines of code
      unsigned long num = x.to_ulong(); 
      cout <<"Decimal form is: " << num<< end;
      // if we've hit 15 items in the current row (i.e. 15 columns), then shift to the next row
      if (row->size() == 15)
        ++row;
    
      // add this to the next column in the current row
      row->push_back(num);
    }
    // resize the last row
    row->resize(15); // this will ensure that there are 15 columns in the last row
    

    NOTES: you’ll have to do some bounds checking (for example if there are more numbers than 15 * 15, the incrementing the iterator row will lead to crap… etc.)

    EDIT: to display, iterate through like a normal array, for example:

    for(size_t i=0; i < matrix.size(); ++i)
    {
      for(size_t j=0; j < matrix[i].size(); ++j)
        cout << matrix[i][j] << " ";
      cout << endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen the following code: [DefaultValue(100)] [Description(Some descriptive field here)] public int MyProperty{...}
Suppose I have the following C code. unsigned int u = 1234; int i
I have the following code in my controller: public ActionResult Details(int id) { var
I have the following fields: Inventory control (16 byte record) Product ID code (int
If I have the following code: MyType<int> anInstance = new MyType<int>(); Type type =
I have the following code which does nothing but reading some values from a
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I'm trying to use opengl in C#. I have following code which fails with
I have the following code in a web.config file of the default IIS site.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.