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
-
1
votes1
answer2495
viewsFunction reverses numbers in array
How this function works in c reversing the numbers? void inverte(int vetor[MAX], int n) { int i,aux; for (i = 0; i < n/2; i++) { // troca posicao i por n-1-i aux = vetor[i]; vetor[i] =…
-
1
votes2
answers590
viewsHow does creating an Array work?
When using the command new() for the creation of any object we call the constructor of the class of that object and obtain the reference to the instance created. However, what happens when creating…
-
1
votes2
answers145
viewsFetch array position from a given term without using the 'inArray' function
In a certain method, from my input, when typing "me" it checks if the fruit exists in this array: ['banana', 'melao', 'uva', 'melancia'] In case, brings me (position 1 - melao and position 3 -…
-
1
votes1
answer685
viewsHow to read the return of the json webservice (WEBSERVICE - JSON)
I have this JSON: { "articleList": { "conversas": [ { "cd_resultadofinanceiro": "24", "cd_feedbackfinanceiro": "61", "mm_resultado": "Tomar as devida providencia judiciais.", "dt_resultado":…
-
1
votes2
answers38081
viewsCalculate vector size
How to calculate the vector size? My code: #include <stdio.h> #include <stdlib.h> int retornaMediana(int *vetor){ int tam=0; tam = sizeof(vetor); printf("TESTE: %d, %d,…
-
1
votes2
answers618
viewsCompare arrays
Good afternoon. I would like to know how I can be comparing two arrays and keeping each pair of value found and print the numbers that were left without pair. Ex: a) 1,2,3,4,5 b) 1,3,5,6,7,5,3 It…
-
1
votes1
answer2006
viewsHow to take data from an array and use Rand without repeating?
I’m doing a quiz, and I saved the answers in an array, I want these answers to appear randomly that doesn’t repeat in the quiz. I used the following code. <?php $times = array('', 'Corinthians',…
-
1
votes1
answer5079
viewsHow to merge an array?
I am writing a program that merges the values of two arrays, with the same amount of values. The program receives as input amount of values in each array. It then takes the values and at the end…
-
1
votes1
answer583
viewsCopia de Vetores
good night! I have a question about how to copy a vector. I declared a "matrix [a][j]" vector and I need to take the arithmetic mean only from the values contained in "matrix[a]", so I need to make…
-
1
votes1
answer642
viewsHow to display a json return in a listview
I’m trying to return a json that result from a select made in php (web service) to my application. The select is here: mysql_connect('localhost','root','ugauga'); mysql_select_db('noise') or die…
-
1
votes2
answers188
viewsInvert order of names in inputs?
I am trying to do an exercise where I have to take 5 names in 5 different input, store them in an array and print them in the same fields but in reverse order to what they were. function…
-
1
votes2
answers860
viewsArray of unique values with foreach
I got the following foreach to pick up the id of the devices that were used in each sector: @foreach($relatorio->Empresa->SetorEmpresa as $setor) {{ $collection[] =…
-
1
votes1
answer403
viewsHow to 'Loop' in Multi-dimensional Array in Bash?
Situation: I need to create a multi-dimensional array script. Example: Table 1 >> Campos id and name Table 2 >> Campos id and telephone Current script: #!/bin/bash declare -A arr…
-
1
votes1
answer137
viewsHow could you create the array_column function in versions prior to PHP 5.5
According to the PHP Handbook, the function array_column is available from PHP 5.5 It returns the value of a "column" of a multidimensional array in a single array. Example: $records = array( array(…
-
1
votes2
answers384
viewsError while removing Arraylist item
I’m "playing" with the canvas (android) and I’m having trouble removing element from an Arraylist. The app works like this: The user clicks on the screen, a ball appears that goes up but I want to…
-
1
votes0
answers96
viewsArray list with equal values
Well I have a list of arrays that I bring of a query of the bank, within that query I have equal products, as I do to store in another array all the elements that are equal? array:6 [ 0 => {#209…
-
1
votes1
answer70
viewsArray, delete value
Good afternoon, someone can get some hint for an exercise in which it is necessary to go through an array and if you find a certain value delete it from the array, this in Assembly. Any hint?
-
1
votes2
answers260
viewsHow to check the 4 vertical and horizontal elements in a matrix based on the current position?
Let’s assume I have a matrix this way: $matrix = [[0, 1, 1, 0], [1, 1, 1, 0], [1, 0, 0, 0]]; Imagine that you are making a loop and capturing the position of this matrix as the example below, being…
-
1
votes1
answer417
viewsHow to pass an integer with two digits, causing each digit to be in a position in the vector?
I make the sum of two numbers 5 and 5, how to pass the result (10) as follows: vetor[0]=1 and vetor[1]=0, that is, separate the result for each position of my vector, without the vetor[0] receive…
-
1
votes1
answer56
viewsAssembling a CAKEPHP Array
Guys, I need some help setting up a bad array here. I got a calendar (bootstrap Calendar) ready and I’m trying to implement it on my site with Cakephp. All right with the layout but when searching…
-
1
votes3
answers771
viewsHow to put two $Row results into variable?
The code below gives error, it does not add the results of $row, only the comma and the dot. What to do? Code that doesn’t work mysql_select_db('cadastro',$conexao); $sql="select * from usuario";…
-
1
votes1
answer151
viewsArray receiving two objects
I have two objects and wanted to create an array this way => [{"loj_codigo":2,"loj_fantasia":"teste 1"},{"loj_codigo":1,"loj_fantasia":"teste 2";}]} I am receiving the following objects =>…
-
1
votes1
answer960
viewsHow to sort an array of objects in java
Hello, I have a class teams where they have scores (int), winning number (int), defeats (int) etc. Within the method main, I have an array of 20 teams and need to sort them by the score, if the…
-
1
votes2
answers215
viewsInsert a dot in the penultimate variable item
I have a variable with the value "14013" and I’m trying to insert a point to have the following value "140.13" in my loop. for (var i in teste) { for (var j in (teste2[teste[i]])) { valorFinal[j] =…
-
1
votes2
answers1085
viewsHow to test whole arrays in javascript?
Good night! I need to create a function that accepts an array of numbers and returns true if it contains at least an even number and false, otherwise. The code below even does this, SQN: var…
-
1
votes1
answer133
viewsIs there any way to access a position by string?
There would be no way to access a position using a string? Example: int vetor[1000000]; vetor["abc"]++; I know it’s crazy of me, but... "abc" = 01100001, 01100010, 01100011, 00000000 (null…
-
1
votes2
answers97
viewswarning for empty in_array
I have a code that to generate a PDF it checks what is marked in the checkbox. But if I don’t mark anything, it still opens the PDF, only with the blank sheet. It has how to make a if that if…
-
1
votes1
answer46
viewsSame numbers in the key-value pair of an array, but random
Assuming I have one array in this way: array(10, 11, 12, 13, 14, 15) I’m trying to make a way to get as a result, a array with key-value pairs, but randomly without pairs being equal. For example:…
-
1
votes1
answer106
viewsSort array php
I have a array, in which values are arrays. How can I order the first array, accordingly with a value that is in the second array? Example: array(array(id=>5), array(id=>2), array(id=>1),…
-
1
votes2
answers512
viewsHow to get the values of an array from a key
I need to get the values ( $src ), inside this foreach, of each key separately in this array: <?php foreach( get_post_gallery( $post->id, false ) as $key => $src ) { echo $key; //resultado:…
-
1
votes2
answers203
viewsErrors with C array manipulation
Through the following code: #include<stdio.h> #include<string.h> int main(){ //Declaração de Variáveis char jogo; char times[20][15] = {"Corinthians","Atlético-MG","Grêmio","Santos","São…
-
1
votes2
answers161
viewsSearching a javascript array
How to search within a javascript array? The solution I use is a gambiarra. x = ['a','b','c','d']; if ( x.indexOf('a') != -1) { console.log('Verdadeiro'); } else { console.log('Falso'); }…
-
1
votes1
answer112
views -
1
votes2
answers159
viewsModular programming in Java, called methods
He needed help to put the smaller and larger method to be "heard" in the main method. The logic of the program is to show the user what is the highest and lowest value of a vector. CODE: import…
-
1
votes1
answer57
viewsAccessing information from an Object
How would I access Type and cm with that array? object(stdClass)#38 (3) { ["op"]=> string(1) "&" ["c"]=> array(1) { [0]=> object(stdClass)#32 (3) { ["type"]=> string(10) "completion"…
-
1
votes3
answers807
viewsRemove row from an array
How do I remove the line without getting blank? N7 G90 N8 G26 RA 10.840 N9 G54 G92 X115.00 Y25.00 N11 C5 N12 D14 N13 G42 G01 X76.3276 Y-19.86 Having to stay that way: N7 G90 N8 G26 RA 10.840 N9 G54…
-
1
votes2
answers95
viewsTurn a JSON string into a non-associative array in PHP
Good afternoon, would like to convert a string into a non-associative array in PHP, functions like json_encode/json_encode are not working properly. String: word =…
-
1
votes2
answers234
viewsWhy is the recursive function return not being used?
What happens when I call a function, recursively, without assigning its return to a variable? Why there is no need, in this case, to assign the function mergeSort explicitly the variable array?…
-
1
votes1
answer1990
viewsPriority queue implementation using vector
I am implementing a priority queue through an array, my method for insertion works normally: public boolean inserir(int n){ if(estaCheia()) { return false; } if(estaVazia()) { fila[nItens++] = n;…
-
1
votes1
answer176
viewsError accessing string array
I have the following code: #include <stdio.h> #include<stdlib.h> #include<string.h> int main() { char v[]= {'Brasil', 'Alemanha', Japão'}; int i = 0; for (i=0; i<4; i++){…
-
1
votes1
answer1521
viewsComparison of vectors in C
I’m currently trying to establish a comparison of two vectors in C. My code structure is as follows:: int iguais(int *v1, int *v2, int tam) { int i, cont = 1; for(i=0; i<tam; i++) { while(*(v1 +…
-
1
votes3
answers16786
viewsChange object value
I have an array with objects similar to this: [{ name: '2015', data: [...] color: 'orange' }, { name: '2016', data: [...] color: 'red' } ] I’d like to change the value of name for another name, like…
-
1
votes1
answer186
viewsHow to assemble a dictionary from two arrays, one from keys and the other from Swift values
I have two arrays containing information of courts and players. Need to put in a tableview this data, being that the sections of the table would be the blocks and the values, of each section, would…
-
1
votes2
answers74
viewsVector that generates elements
I would like to generate a vector where your next position element is added to 1. For example: be a vetor[3], would like that v[0] = 1 and v[1] = v[0] + 1, v[2] = v[1] + 1 and so on. How would you…
-
1
votes1
answer80
viewsProblems with Javascript arrays
Well, I’m having some problems with the following code snippet: alert(lineOut[i].trim() + " - - " + lineOut[i + 1].trim()); Uncaught Typeerror: Cannot read Property 'Trim' of Undefined(...) The…
-
1
votes1
answer180
viewsHow to check for certain values in an array?
I have the variable $search_dorms who returns me Array ( [0] => 1 [1] => 2 ). She can return too Array ( [0] => 1 [1] => 2 [2] => 3 ) Or simply Array ( [0] => 1 ) I am trying to…
-
1
votes2
answers1666
viewsHow to create an array with months
Good afternoon, I am providing maintenance on a code that features a graph, the X axis presents the last 11 months and the current month, who wrote it entered the months manually and wanted to…
-
1
votes0
answers37
viewsWhat is the difference between Jagged arrays and multidimensional arrays, and what application is indicated for each one?
I would like to better understand the difference between Jagged arrays and multidimensional arrays, and how each type should be applied in practice.
-
1
votes3
answers786
viewsHow to take several arrays with 1 single index and put in a single array?
I’m 3 days trying to solve a problem, I can’t get multiple arrays with 1 single input and put and a single array. EX: Está imprimindo assim: Array( [0]=> "MT" ) Array( [0]=> "MG" ) Array(…
-
1
votes0
answers23
viewsGenerate byte image array to insert into BD
I need to save a jpg image in the database in a BLOB column, however, everything I tried didn’t work out, what I’m testing now to try to generate the byte array is this: ini_set('memory_limit',…