Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello...

i want to create a function that returns me the highest element of arrays...i m trying to draw the structure as follows...

1
23
456
8932

Above,there are four arrays.i want to iterate in each of the array and find the highest element in each of them and display on the screen...

The number of arrays is depending on the user (i.e. not fixed to four) and the user will enter the element of each array like
(1 2,3 4,5,6 8,9,3,2) i.e the element in each array are seperated by commas and element in different array are seperated by blank spaces. The signature of the function is as...

public void Array (int NumberofArrays,int ElementofArray)

how do i enter the element of the array in the above mentioned manner and how do i create the array depending upon the user input...i m creating arrays in a loop like

for ()
{
int[] array=new int[]
}

but this loop will create the arrays of same name...

can any one help plz...
Posted

Your code is not tagged, and is incomplete. To create an array of arrays of user defined size, you may be able to use the new statement to create an array of arrays with a size you specify. If not, you need to use a list of lists. You want an int[][] to create an array of arrays.
 
Share this answer
 
Why dont you use Array of Arrays or a collection of Arrays
Then you will not face the problem of identifying Arrays uniquely.

Or describe the process in details so that we can suggest any other approach :-O
 
Share this answer
 
Try using a Jagged array. The Basic syntax is something like:

C#
int[][] arr = new int[5][];

for (int row = 1; row <= 5; row++)
{
    arr[row - 1] = new int[row];

    for (int col = 0; col < row; col++)
    {
        arr[row - 1][col] = col + 1;
    }
}


This creates a structure like this:
1
12
123
1234
12345
 
Share this answer
 
Thanks very much for all of your replies....

I have done with my problem and i used arrays of arrays...

thanks all guys...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900