Most voted "array" questions
An array (array, vector, or matrix) is an ordered data structure representing a collection of elements (values or variables), each identified by one or multiple indices.
Learn more…3,046 questions
Sort by count of
-
3
votes1
answer625
viewsJavascript - Soma e Group By em Array
I would like a tip/help. I’m working with a number of files JSON, and applying filters to them as the user advances in the system. So far so good, I managed to do it quietly using the .filter(). My…
-
3
votes1
answer84
viewsSimilarity of elements in different vectors
I have two vectors: A <- c("RS", "DF", "CE") B <- c("Porto Alegre - RS", "Brasília - DF", "Fortaleza - CE", "Porto Alegre - RS", "Acre - AC", "Recife - PE") and a function: f <-…
-
3
votes1
answer2225
viewsAdjacent values
I need to create an algorithm that calculates the minimum distance value between the indexes of a matrix that contains adjacent values. But what are adjacent values someone could give me examples?…
-
3
votes1
answer778
viewsTypedef struct with C character array not working
I’m trying to create a kind of constructive data, but I’m having problems with the strings. typedef struct { char nome[30]; int idade; } p; p x,y; x.nome = “ana”; x.idade = 20; y.nome = “caio”;…
-
3
votes1
answer64
viewsWould an alphabetical sequence counter be possible?
I’m making a code in Pascal where one of my arrays has alphabet values (from A to Z) for a personal project of the type Questions and Answers/ Meaning A to Z: aux[1]:= 'a'; aux[2]:= 'b'; aux[3]:=…
-
3
votes1
answer64
viewsHow to identify exactly which record has changed from one list to another? By ID
Hello. I have 2 lists being mounted in javascript, based on the rule: Do you have flag queries Then stay in the Array: clientesDownloadTrue Do you have flag queries Then it stays in the Array:…
-
3
votes2
answers312
viewsReplace list() by placing value in each index of an array
So I was browsing php.net when I came across List() and went to see what it was for. Then they gave me the following example: $info = array('Café', 'marrom', 'cafeína'); list($bebida, $cor,…
-
3
votes1
answer524
viewsJava Vector Table Testing
I’m having trouble solving the next code table test, someone could show me the output and how to do it? public class Principal { public static void main(String args[]) { int array[] = {1, 2, 3, 4,…
-
3
votes1
answer196
viewsHow does callback sort functions work internally?
In php, when we want to order a array in a customised way we can use the function usort. I know that for this function to work, we must use values 1, 0 and -1. In case, if I wanted to order this…
-
3
votes4
answers8807
viewsHow to insert a property into a javascript object?
I have the following javascript object: data2 = { "desColigada": "Empresa fulano de tal", "codMatricula": "00555454", "dataImpressao": "23/05/2016" }; I need to know how to insert this array into…
-
3
votes2
answers6824
viewsAutomatically create vector in Python
I’m new to Python and need help with the following: I have a variable (x) that takes an integer value. I want this variable to be used to create a vector with 1 row and (x) columns. This vector must…
-
3
votes1
answer540
viewsDelete item from an array and reorder it - PHP
Is the following: I have an array, sort of like this: $array = [ [0] => 'Fellipe', [1] => 'Fábio', [2] => 'Mateus', [3] => 'Gustavo' ]; I would like it when I remove an item from that…
-
3
votes3
answers734
viewsMysql query with subquery in Nodejs
I have the following structure in the following tables. partner (idParceiro, name, email, phone) example partnerTag (idPartner, tag) What I need to do, a select in the partner table and do a for in…
-
3
votes6
answers2251
viewsRemove all elements from an array that already exist in another
I have two arrays with javascript objects: var a = [{objeto1}, {objeto2}, {objeto3}, {objeto4}, {objeto5}]; var b = [{objeto1}, {objeto2}]; How to do what is in the array b exit the array a?…
-
3
votes2
answers2822
viewsHow to print an integer vector by removing the last comma in Python 3?
I want to print on the screen an array of integer numbers in the same line and separated by comma, and I want to remove the comma that is after the last number. How could I do that in Python? My…
-
3
votes1
answer1231
viewsSorting of string and number vectors
I’m having a problem with a college exercise. Basically it’s a shop system, where I come in with the amount of stores, the amount of products, the name of the products, and the amount of products in…
-
3
votes2
answers15417
viewsHow to add the diagonal of a matrix in C?
Help me in the following exercise: Make a program that defines an integer array of size 5x5. Next, initialize this matrix with random numbers between 5 and 9. Finally, your program must calculate…
-
3
votes2
answers40
viewsHow to sort the position of a matrix automatically?
Example, I have: $matriz = array("Tomate", "Morango", "Melancia"); I would have: ( [0] => Tomate [1] => Morango [2] => Melancia ) But if I do: unset($matriz[0]); I will have: ( [1] =>…
-
3
votes1
answer154
viewsReset repeated values of a matrix
Hey there, guys. I have an exercise where I must populate a matrix with random numbers from 0 to 9 and then replace the repeated numbers (except the first time the number appears) with the number 0.…
-
3
votes2
answers40
viewsFinal value of the array?
This variable of mine: $valor = $cliente->cobrancas[1]->valor; echo '<pre>'; print_r($cliente); echo '<pre>'; Print the values below: stdClass Object ( [id] => 24151 [nome]…
-
3
votes1
answer61
viewsFloat to Byte Array conversion
How can I be performing the conversion of float or integer (if possible) for a array byte in Java. Say: float x=180 Theoretically you would need to create 1 array 2 position bytes. Is there any way…
-
3
votes1
answer409
viewsHow to pass an array as parameters or arguments?
I have two functions: function example($param1, $param2) { echo $param1 . $param2; } function frutas($fruta1, $fruta2, $fruta3) { echo $fruta1 . $fruta2 . $fruta3; } And I also have a variable that…
-
3
votes2
answers895
viewsAdd prime numbers within a vector
I have this problem : Make an algorithm that takes 1500 numbers, calculate and show the sum of even numbers and the sum of prime numbers. So far so good, I was able to filter and add even numbers,…
-
3
votes2
answers132
viewsWhat will be the result of $a?
I was studying PHP and seeing questions, to improve my knowledge in the area. Here is an excerpt from a question: Given an excerpt of code written in PHP language, as the below: $a = array("a", "b",…
-
3
votes1
answer233
viewsHow to group dates from an array?
I’ve got a job to do here and I don’t even know where to start: I have an array of dates to group: array (size=12)<br> 0 => string '2016-08-22' (length=10)<br> 1 => string…
-
3
votes1
answer1613
viewsFind String in Arraylist
ArrayList<String> posicoes = new ArrayList<String>(); posicoes.add("Ricardo;01051509912;gmail"); posicoes.add("Renato;123456789123;hotmail"); posicoes.add("Rodrigo;09873923121;yahoo"); I…
-
3
votes0
answers70
viewsHow do I separate my arrays by Dice?
Text boxes corresponding to the number that the user entered are generated, each text box is accompanied by several checkboxes to choose the type of text. But it comes out like this : Array ( [0]…
-
3
votes3
answers835
viewsHow to go through an array skipping some indices?
There’s a native way to do this? for (var i in vetor) { for (var j in vetor) { if (i == j) { // pula o i break; } } } Is there any way to skip the i within the parentheses of the second for?…
-
3
votes2
answers46
viewsError declaring Jtextfield vector in class
Well, I’d like to store all my JTextField in an array, however, when I define the array, I get the following error: llegal forward reference. Follow the code where I define the array. private…
-
3
votes1
answer2233
viewsCount element values from a PHP array
I got the following array, for example: Array ( [0] => Array ( [ID] => 401675295 [DATA] => 2016-06-28 15:33:07 [TITULO] => Teste [TEXTO] => [TIPO] => 4 [NOME] => JOAO ) [1]…
-
3
votes1
answer347
viewsPHP - Pushing an array within another array
I’m trying to make a array within another and include more data in the array from within, how do I do it ? Follow the attempt code, it’s to generate a json: $data = array( "login1" => "login1",…
-
3
votes1
answer3210
viewsDisplay the position of a given value on a vector in R
I started studies in R a short time ago and I have studied this language a lot. However, I am having difficulties in how to get the position of a vector, that is, the order in which a certain value…
-
3
votes2
answers830
viewsIndex searches on an R vector
In Rstudio how to choose elements of a vector that are in even or odd positions?
-
3
votes2
answers797
viewsWhy can you pass a char vector to the scanf as the direct address or variable?
If the name of the vector or matrix is already the address of the first element, why scanf(), using the primitive types (int, char, float, double) I need to pass the address, being that when we want…
-
3
votes1
answer46
viewsFormatting stdClassObject for array
I have a problem to convert some data into my system, I have the following code snippet that returns an array with a few objects: Array( [4014] => stdClassObject([id] => 4014[registro] =>…
-
3
votes3
answers580
viewsGrab a JAVA array
I am new in java, because of this I have the following situation, I would like to take the array in my case 2 of switch, the problem is that it says the value was not initialized, but I first enter…
-
3
votes3
answers1372
viewsTransforming String into an Array - Javascript
With that return I’m getting the following string: return $data.requestSuprimentos.value; String [[1, X340H22G, 30000, 3], [2, 64418XL, 32000, 1], [3, X644X11L, 32000, 1], [4, 64018HL, 21000, 1],…
-
3
votes1
answer792
viewsHow to set the size of an array of bytes dynamically?
I’m developing an application that creates a arquivo.txt and saved in a column of my table in the database. The problem is in the query of that file. What happens, when I want to do the query I have…
-
3
votes1
answer616
viewsSort array alphabetically and show only first name of each item
I am totally layman in Java, wanted help to finalize an exercise. The statement is this: "write a program that receives an array with the name complete of 10 people and present an array with only…
-
3
votes2
answers244
viewsHow to sort array decreasingly?
I have the following problem, after making a array `push, I want to return the amount of repetition of a term for this: $key =…
-
3
votes2
answers82
viewsConversion of byte array to string when compiling revealing the string in C compiled code
I am using the function below to make the conversion of byte array for a string, but when analyzing the compiled code I note that the string is clearly shown (using an Hex editor), what I do not…
-
3
votes1
answer11435
viewsWhat is java.util.Concurrentmodificationexception?
What causes this exception? How to prevent this exception? How to correct it? Example: I have an Arraylist where I keep several films in a table (Jtable) where I remove the films so as not to rent…
-
3
votes1
answer98
viewsR - How to sample pairs from an array without repeating values?
I’m trying to create 100 pairs from a 200 value vector. I built a vector following a normal distribution as follows: vetor=rnorm(200,mean=30,sd=6) And now I want to extract 100 pairs of these…
-
3
votes2
answers3831
viewsHow to use vectors/arrays in Java?
Hello, I am very layy in Java and need to use a variable storing several others. How can I do this? I have the following: LatLng ponto1 = new LatLng(-19.924312,-43.931762); LatLng ponto2 = new…
-
3
votes1
answer2946
viewsHow to transform this Json into an object Arraylist?
I am working on a project where I am doing a database query and need to return a list of users from the database to be listed in my application. I have the following Json line (returned by the…
-
3
votes3
answers14457
viewsTraversing Object array and accessing a value
Good afternoon guys, I’m having a difficulty, where I need to access an element of an array of OBJECTS, I’m not being able to access with foreach, or for. I need your help! The array of objects:…
-
3
votes1
answer75
viewsMerge two arrays
I have the arrays: $tamanho = ['P', 'M', 'G']; $quantidade = [1, 3, 5]; The end result would have to stay that way: $final = [ ["tamanho" => 'P', "quantidade" => 1], ["tamanho" => 'M',…
-
3
votes1
answer60
viewsSyntax ':value' in the array
I saw this syntax in the 'Resources/lang' area, where authentication messages are preset. And I came across the following code: <?php return [ 'throttle' => 'Too many login attempts. Please…
-
3
votes2
answers340
viewsDifference between Java Arrays
What is the problem in Android of not setting the size of the array? I’ve seen in several places that it should be started with a default value. What’s the internal difference of doing this:…
-
3
votes2
answers57
viewsInitializing Array from a new class
Considering two classes in C#: public class aClass { public string afield; } public class bClass { public aClass[] bfield; } I plan to start the variable as bClass cVar = new bClass();…