apmatrix

This is a discussion on apmatrix within the C++ Programming forums, part of the General Programming Boards category; can anyone show me how to display an apmatrix of random numbers on screen. if not an apmatrix- how about ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    5

    apmatrix

    can anyone show me how to
    display an apmatrix of random numbers on screen.
    if not an apmatrix- how about a 2d array?

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    apmatrix

    #include <iostream.h>
    #include <time.h>
    #include <apmatrix.h>

    int main()
    {
    apmatrix <int> MyMatrix(10,10); //creates a 10 x 10 grid
    srand(time(0)); //used for random numbers
    int x,y;

    for (x=0;x<MyMatrix.numrows();x++)
    for (y=0;y<MyMatrix.numcols();y++)
    MyMatrix[x][y] = rand()%10; //assigns random numbers 0-9

    for (x=0;x<MyMatrix.numrows();x++)
    {
    for (y=0;y<MyMatrix.numcols();y++)
    cout << MyMatrix[x][y];
    cout << endl; //prints numbers as a grid instead of linearly
    }

    return(0);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Apmatrix error.
    By two31d in forum C++ Programming
    Replies: 5
    Last Post: 10-18-2005, 07:38 PM
  2. Apmatrix.h -> vector
    By JoshR in forum C++ Programming
    Replies: 13
    Last Post: 03-30-2005, 08:49 PM
  3. APMATRIX help please.
    By NewbieUser in forum C++ Programming
    Replies: 5
    Last Post: 05-04-2003, 07:19 PM
  4. Some Quick Help
    By quiksilver9531 in forum C++ Programming
    Replies: 12
    Last Post: 11-23-2002, 01:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21