What do you mean by "matrix", what do you mean by "remove"?
For the first part I have to make a multidimensional array(matrix). When I make one (any size) I have to find longest subarray of positive numbers in one row and compare it with other rows(if I my row has more then one subarray of positive numbers I have to include the longest). When comparing other rows with elements of subarray of positive number if I find same numbers from subarray in that row I have to "remove" that row.
The other part is making a matrix with double pointer and doing the same thing with subarray and comparing rows.
If I wasn't so clear on what I have to do, please contact my via PM. :P
You can't just remove a row from a statically allocated array, and it's a little tricky to remove a row from a dynamically allocated array.
For statically allocated arrays the best you can do is to copy the contents of all the rows you don't want to remove up to fill in the gap, then the last row in the array is considered unused.
For example: if you have an array of 10 rows, in order to remove row 2 you have to copy rows 3-10 up to rows 2-9 then somehow mark row 10 as unused. The array still has 10 rows, but your program would consider the last row as unavailable.
For dynamic arrays when you want to remove row 2, do it in several steps
Step 1. malloc() a new array the same size as the original but with 1 fewer rows.
Step 2. copy all the rows from the original to the new, omitting the row to be deleted.
Step 3. free() the original array
Step 4. set the pointer of the original array to be that of the new array.
realloc() might work here but only if the row to be deleted is the last row in the array, so it's not useful in your program.
longest subarray of positive numbers in one row
I don't know what you mean by that. Does it mean the array can contain both positive and negative numbers? Post a simple example to illustrate the idea.
Edited 2 Years Ago by Ancient Dragon
1 2 3 -5 6 2
2 3 -5 -6 -4 2
-2 2 5 1 7 -8
-5 -6 2 5 1 7
So it this 'matix' I need to find the longest array of positive numbers in one row(not column). In this case it's 2 5 1 7 and 'remove' it from row 3 and 4.
Oh, yea. Forgot to say that you can use real numbers in matix. xD
Forgot to say that you can use real numbers in matix.
That's ok -- you can't put irrational numbers in an int anyway.
Finding the largest array of positive numbers should be fairly straight forward. Just cound the number of positive numbers until either the end of the row is hit or a negative number is found. You will probably need to use two other arrays to do that.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Hi. Im using vb 2010. I want to dynamically add textboxes to my form by clicking on a button. I've google searched and so far this code worked:
Private Sub btn_addline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_addline.Click Dim txtB1 As New TextBox Dim i For i = ...