Array output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Acrylic
    New Member
    • Apr 2007
    • 3

    #1

    Array output

    hi there, I am a newbie programmer and I have the following problem: I need to have a 2-d array that will have 3 columns and 100 rows. below that columns i would like to store randomly numbers. Check out my code and if you have any ideas of how to print the array correctly, please let me know. Thank you in advance

    int node = 1;
    int count = 0;
    int[][] NodesArray = new int[101][3];
    NodesArray[0][0] = nodesID; // get a value from input
    NodesArray[0][1] = FilesOfNodes; //get a value from input

    for (int i=1; i<=100; i++)
    {
    NodesArray[i-1][0] = node;
    for(int j=1; j<=2; i++)
    {
    NodesArray[i-1][0] = 1 + (int)(Math.rand om() * 50);
    count++;

    System.out.prin tln(NodesArray[i-1][0] + " " + NodesArray[i-1][0]);
    }
    node++;
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Acrylic
    hi there, I am a newbie programmer and I have the following problem: I need to have a 2-d array that will have 3 columns and 100 rows. below that columns i would like to store randomly numbers. Check out my code and if you have any ideas of how to print the array correctly, please let me know. Thank you in advance

    int node = 1;
    int count = 0;
    int[][] NodesArray = new int[101][3];
    NodesArray[0][0] = nodesID; // get a value from input
    NodesArray[0][1] = FilesOfNodes; //get a value from input

    for (int i=1; i<=100; i++)
    {
    NodesArray[i-1][0] = node;
    for(int j=1; j<=2; i++)
    {
    NodesArray[i-1][0] = 1 + (int)(Math.rand om() * 50);
    count++;

    System.out.prin tln(NodesArray[i-1][0] + " " + NodesArray[i-1][0]);
    }
    node++;
    }
    The same approach you used to enter the values can be used to print the values.

    Comment

    Working...