Questions tagged as 'array'

2
answers

How to store the value of the indexes of this JSON in variable?

I have a function in php that returns this to me. [{"id":81,"username":"usuarioteste23"}] How can I save a Username and variable in a variable? Thank you.     
asked by 21.01.2016 / 11:57
2
answers

Convert XML to array in PHP

I'm looking for article names through this link: [http://api.elsevier.com/content/search/index:SCIDIR?query=heart+attack&apiKey=20d0c7953f56925f725afe204869dadb&xml-decode=true&httpAccept=application%2Fxml][1] You are returning...
asked by 20.01.2015 / 16:55
3
answers

Assign type to array in PHP

I know that PHP is a poorly typed language. But is there any alternative way to "type" a array in PHP? Example, I can do this below to force a given data type to be given in a function. function exemplo(Classe $valor){ // meu cód...
asked by 04.02.2015 / 19:54
6
answers

How to do an array subtraction

Assuming I have an array let arr1 = [ {nome: 'Fulano', idade: 19}, {nome: 'Ciclano',idade: 20}, {nome: 'João', idade: 20}, {nome: 'Maria', idade: 30}, {nome: 'Teste', idade: 52} ] I have another let arr2 =...
asked by 23.02.2018 / 20:56
2
answers

Determine how many "islands" an array contains

I need to create a program that receives as input an array size (up to 300 per 300) and the array values that will be stored (it can be only 1 or 0). I must determine the number of "islands" (clusters of 1) formed and display for the user. I can...
asked by 14.10.2017 / 06:03
1
answer

Is it possible to initialize only some members of an array in C already in its definition?

I know you can do this: int a[5] = { 0, 3, 8, 0, 5 }; or int a[5]; a[1] = 3; a[2] = 8; a[4] = 5; Can you do the same in just one line, already in the definition?     
asked by 22.03.2017 / 12:33
1
answer

Error undefined using replace ()

I'm trying to make a kind of people marking, I tried, but I did not succeed. Where is the error ?? var nome =["Ana", "João", "Maria", "José"]; var frase = "@[1] é casado com @[0], e @[2] é casada com @[3]."; var msg = frase.replace(/...
asked by 13.11.2015 / 00:01
1
answer

Recursive analysis of a vector

QUESTION: Write a recursive function that parses the elements of a vector and returns one of the following codes: 0 Disordered elements 1 Items sorted in ascending order 2 Constant elements 3 Items ordered in descending order int A...
asked by 04.10.2015 / 15:37
2
answers

Why does the linear search return for element not found have to be -1?

Why should I return -1 at the end of a linear search if the element was not found? int linearSearch(int[] list, int size, int key){ for(int index=0; index<size; index++) if(list[index]==key) return index;...
asked by 23.11.2017 / 01:54
1
answer

How to insert dynamically into a std :: array?

I'm migrating from C language to C ++, and I want to stop using traditional C language media as the vector of it. Is it possible to use std::array to insert elements dynamically as in std::vector ?     
asked by 08.11.2016 / 15:52