Questions tagged as 'array'

2
answers

"Operator" brackets [] in creating the arrangement in C

Whenever I look for what the brackets operator [] does, even in the tables that show all operators in C, it appears that it serves to access an element of an array. However, this is not always the case, for example in the case where the a...
asked by 12.09.2018 / 16:20
2
answers

Remove empty positions from an array

I'm passing array via GET to PHP and then sending to the client side (JavaScript). When I get it it looks like this: m_prod = [5,,,,,,,,6,,,,,,]; In other words, it is including a space in the positions that do not contain a v...
asked by 19.11.2014 / 15:47
2
answers

How to shorten the process of creating an array without the need to write all indexes?

For example, if I need to create an array with 20 spaces, do I always have to do this? $teste = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19); Or is there any way to shorten this process, from 0 to 19? Something like: $teste =...
asked by 30.06.2017 / 19:38
3
answers

How to make a foreach for an array of arrays?

How can I make a foreach for an array of arrays like this: array ( [option1] => 2 [option2] => array ( [name] => "ola mundo" [id] => "123456"...
asked by 03.10.2014 / 16:55
4
answers

Even or odd of an array in PHP

I need to create an array and tell if the values inside it are even or odd. I made the code this way: <?php $par_ou_impar = array(2,3,4,56,5,42,98,100); for ($i = 0; $i < count($par_ou_impar); $i++){ if ($par_ou_impar % 2 == 0)...
asked by 31.01.2016 / 18:18
3
answers

JS - Array of objects for array array

How do I convert an array of objects to an array of arrays in javascript? I did this, but it returns an array of objects var items1 = new Array(); $.map(objResposta, function(value,index) { teste = new Array(); items1.push(val...
asked by 19.12.2016 / 13:45
4
answers

How to test the condition on a vector?

I have to do a program that reads a text, where each first letter of each word of the text is replaced by a character (*). I can not compile correctly, I believe the problem is in my condition ( if ). #include <stdlib.h> #include &...
asked by 21.09.2015 / 00:37
2
answers

Separate values from each array

Good day, people, okay? I have the code that prints the different values found in 2 arrays and those values get stored in the different variable ($ different) I need to know how I can print these values stored in different but telling which arra...
asked by 05.04.2016 / 14:28
2
answers

How do I get a random string from a list of strings?

Code: nomes = new string[5]; nomes[0] = "José"; nomes[1] = "Carlos"; nomes[2] = "João"; nomes[3] = "Miriam"; nomes[4] = "Estela"; I put an array, but it does not have to be array, it can be with list or something else that gets fas...
asked by 30.05.2014 / 15:46
6
answers

Convert an array of floats to integer

Suppose the following: import numpy as np a = np.array ( [1.1, 2.2, 3.3] ) How to convert this array to int without having to iterate each element or using another array? Why to: b = int(a) It gives an error because it is on...
asked by 06.01.2014 / 00:50