05-29-2023 01:28 PM
Hello, I have this task :
Generate a string consisting of N random integers between 1 and 1000.
Then separate the string into 5 other substrings, consisting of:
Substring 1 – all numbers in the string divisible by 3
Substring 2 – all numbers in the string divisible by 5
Substring 3 – all numbers in the string divisible by 6
Substring 4 – all numbers in the divisible string
All i manage to do is this, but i don;t know how to divide it and after i have to introduce it into the table.
05-29-2023 01:41 PM - edited 05-29-2023 02:15 PM
05-29-2023 01:45 PM - edited 05-29-2023 01:46 PM
What i need is to know how to get the elements of an array that are divisible/divided by 3 (%3, for labview VI), and put them into another array.
05-29-2023 01:59 PM
You cannot divide strings, but quotient&remainder will give a remainder of zero if the number is divisible.
Maybe this can give you some ideas.
As I said, you can have conditional output tunnels for each desired divisibility. I recommend to go back to the learning resources.
05-29-2023 02:47 PM
Thank you for your help. My question is, despite what i did (let's forget it), is: "How do i take numbers from 1D array, divide them by three, and if the remainder is 0, put them in another array"
That's what i want to know. The thing about strings and that table is that, after i see if and element is divisible by that number, i have to introduce it into the table. What i want to know is the first question.
05-29-2023 03:06 PM - edited 05-29-2023 03:11 PM
@ShadowRise wrote:
Thank you for your help. My question is, despite what i did (let's forget it), is: "How do i take numbers from 1D array, divide them by three, and if the remainder is 0, put them in another array"
Did you click my earlier link about conditional tunnels? Was there anything not clear? If you auto index your number at an output tunnels and make that conditional, you'll get a 1D array of only the elements where the condition is true. Once you understand that, the rest will fall into place. Good luck!
@ShadowRise wrote:
That's what i want to know. The thing about strings and that table is that, after i see if and element is divisible by that number, i have to introduce it into the table. What i want to know is the first question.
Once you have all your special 1D arrays (one for each divisibility), you can format them into strings and build/transpose them into a 2D array suitable for the table indicator (keep in mind that 2D array cannot be ragged, so all rows/columns will be padded to the longest with empty string elements.
05-29-2023 03:16 PM
I read it and now it works, thank you very much. I will post my solution later.