Questions tagged as 'array'

2
answers

Create a vector with the Levels of a factor in r

I have a column in my data array as follows: > as.factor(matriz$especime) [1] 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 [29] 3 3 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 7...
asked by 25.04.2018 / 23:05
2
answers

Why did a dynamic array work without the use of malloc?

The following code snippet follows: int main(void) { int tam, vet[tam]; printf("\ndigite tam: "); scanf("%d", &tam); return 0; } I did not know this worked because I'm typing the vector size at runtime. For me, this was...
asked by 07.10.2014 / 18:54
2
answers

check if GET value exists or not

I created an array calling names, inside that array I have 3 names $nomes = array ('carlos', 'maria', 'jose') Later in the code I'm trying to create an if where it checks if the value of GET exists inside this array, but I'm not getting it....
asked by 02.08.2014 / 16:38
3
answers

Problem getting random integer values in array

Eclipse does not point to any errors in the code, but does not execute. package gerarOrganizar; import java.util.Random; public class GerarOrganizar { public static void main(String[] args) { int i=0; int[]ranF =null;...
asked by 08.10.2014 / 19:10
3
answers

Problem when ordering an array with sort ()

One of these occurs when I want to sort an array of numbers. Ex: var a = [44,7,5,6,4,2,1]; a.sort(); console.log(a); The expected result would be: [1, 2, 4, 5, 6, 7, 44], but what is always returned to me is [1, 2, 4, 44, 5, 6, 7]....
asked by 16.03.2016 / 15:36
4
answers

Problem accessing array element

I have a problem with the function below that truncates all words so that they have a maximum of N characters. For example: if the string contains: "freedom, equality and fraternity", the invocation of truncW(t,4) should give "libe e...
asked by 15.03.2015 / 19:34
3
answers

Simplifying an Array - PHP

I have a multidimensional array where the data is as follows: Array ( [0] => Array ( [0] => Array ( [0] => Brasil [1] => Franca [2]...
asked by 04.07.2016 / 22:49
3
answers

Access value of a property using a String

Suppose I have the following object: var pessoa = { nome: "João", animais: { cachorro: "Rex", gato: "Pipoca", } } I need a function to do something like this: var gatoDoJoao = pessoa["animais.gato"]; I know...
asked by 28.11.2016 / 02:16
4
answers

In a sentence, how to know which word with fewer characters?

In one sentence, how do you know which word has fewer characters? What I did was to transform the string into an array, but I was only able to return the smallest when it comes to an array of numbers, using Array.min But is there any method or b...
asked by 24.08.2018 / 22:38
3
answers

How to use forEach in associative JavaScript array

I'm seeing here that the length of an associative array in JS gets zeroed. How do I access those values then? Example: let myArray = []; myArray['zero'] = 0; myArray['um'] = 1; myArray['dois'] = 2; console.log(myArray.length);...
asked by 29.11.2018 / 14:58