Posts by Isac • 24,736 points
820 posts
-
2
votes2
answers77
viewsA: How to get the instance itself (this) in a callback?
You can create a reference to the object itself that you then use inside the callback: class Cat { constructor(name, picture) { this.name = name; this.picture = picture; this.count = 0; // ... let…
-
3
votes2
answers1641
viewsA: Pass pointer pointer as argument for a function
The problem is in malloc within the alocaMatriz. When the function alocaMatriz is called is copied the value of int **matriz; who is in the main into the function, so the change within the function…
-
2
votes2
answers126
viewsA: Take over positions of an array after comparison with another array?
A solution to the problem itself is by using the filter, thus: let diferencas = dados.filter(x => results.indexOf(x) ==-1 ? x : false ); In which the filter part of the array dados which is the…
-
3
votes1
answer126
viewsA: Stack/Stack with priority in c#?
I start by indicating that in your code the Pop is not updating the top widget, so a Peek after Pop does not return the correct element. You can fix this problem as follows: public T Pop() { if…
-
1
votes3
answers898
viewsA: Validation and counting of days of a date
Just as Maniero said by subtracting the date in question with the date beginning on the 1st of the same year, he gets an object of the type TimeSpan which represents the time difference between two…
-
0
votes1
answer935
viewsA: How to inform the largest consecutive sequence?
It is important to separate the introduction of values from the logic of accounting. In this case it even simplifies because the accounting cannot be done for all values because it considers the…
-
2
votes1
answer125
viewsA: Data Structure / List C#
For the function you need just make a for about the amount of elements to remove and go modifying the beginning of the list for the element that is exactly following. In addition it is also…
-
2
votes2
answers1149
viewsA: How to Put color over the image when passing the mouse?
This type of effect can be done in several different ways with css and Jquery. Using only css can do by placing 2 Divs, one inside the other. The first with the image and the second with the black,…
-
2
votes2
answers117
viewsA: "java.lang.Outofmemoryerror" error with List
Division is not being done by the right values here: aux = x / i; That always divides by the original value and not by the last. Dividing by the original the aux always stays in 18 (36/2) and never…
-
2
votes2
answers65
viewsA: What is the behavior of a method that returns integer within the if?
When you do not assign the return of the method to a variable, as here: System.out.println("remover(19) = "+remover(19)); if (remover(19) == -1) { System.out.println("O vetor vB está vazio!"); }…
-
2
votes1
answer2436
viewsA: Copy list simply chained in C
The flip function has a variable with the open value: NO* atual = //inicio da lista resp Which generates a syntax error because the value and the ;. Just as logic does not do what is intended.…
-
0
votes1
answer1589
viewsA: Double chained list printing in reverse order
The problem is only in function insereInicioLista that has some incorrect things. The pointer fim it is not necessary since it is inserting itself at the beginning always, and if it were necessary…
-
1
votes1
answer87
viewsA: Javascript array with JSON object
The code you are using to try to group products has some things that do not play with the goal. Start by checking if the first category plays with the first category of the first product: if…
-
0
votes2
answers78
viewsA: Doubt about vector in C
My answer is an alternative solution to the program that has already corrected simultaneously the problems that Anderson Henrique had already pointed out. And why not use structures? If all the…
-
1
votes1
answer378
viewsA: Vector: Register 5 names and their heights, then show all in ascending order.
In almost all situations that have various information associated with each other the ideal is to use classes, which organize and facilitate logic. If in your example you would register names and…
-
1
votes2
answers914
viewsA: Put vectors in order. JAVA
I am responding as an alternative to Bruno’s solution, using Java 8 and Streams. And while I may not be as educational is certainly interesting. The reading part would be equal and separate from the…
-
2
votes1
answer385
viewsA: Error in Pascoa calendar algorithm
There are some points in your converted code that need to fix: mes='Janeiro' String delimiter are double quotes " and so your assignment of the months is not correct and should be mes="Janeiro";.…
-
2
votes1
answer133
viewsA: a div in another div with position Absolute will have position Absolute too?
Not really. Any html element has position as static, unless another value is specified explicitly. Source, Source 2 It is also possible to confirm this as the sample html that put used the browser…
-
3
votes1
answer4847
viewsA: How do I put the value of a variable inside a textbox?
One TextBox even when defined with the attribute ReadOnly to True can have your text modified programmatically by directly modifying the field Text: nomeDaMinhaTextbox.Text = "outro texto aqui"; Or…
-
1
votes1
answer44
viewsA: Correlate vectors through the index and assign different values
If you need each "Tuplo" found to be replaced by an equal random value in the two positions but different from successive tuples, just generate a new random before each exchange: for i in indices:…
python-2.7answered Isac 24,736 -
4
votes3
answers4572
viewsA: Clear Field with Javascript
You can build another function that interprets the result of the date check and clears if you don’t receive true: function limparDataInvalida(campo){ if (!VerificaData(campo.value)){ campo.value =…
javascriptanswered Isac 24,736 -
0
votes2
answers1291
viewsA: Show Hide Javascript Button
If it is something that does not change after the page is loaded the best is to do it on the server side soon, putting directly the right style in the <div>. <div id="descricaosolucao"…
-
1
votes1
answer340
viewsA: Correlating vectors through the Python indexes
Starting from the code of your last question you just need to create a list of indices and save the elements where that code is placing the random ones. Then use it to replace in the second vector…
-
1
votes1
answer103
viewsA: How to repeat Json data in a list
It is only necessary to do the parse once, and in your case was doing several times. As is a list of students you get can use a forEach to go through all and show the corresponding fields of each…
-
1
votes1
answer2324
viewsA: Locating values in a python array and assigning specific values
For this case the random value is generated at the beginning and only once, which will then be applied in all substitutions. These can be done based on a list of values to be replaced, and running…
-
0
votes2
answers422
viewsA: Problems converting integer to string (stringstream) c++
The error is indeed in this line: hexa+=hexa_aux.str(); That you should just assign, not concatenate, like this: hexa=hexa_aux.str(); That will make the program work. Although this can be…
-
2
votes1
answer70
viewsA: Correlating values in Python Arrays
For this it is only necessary to modify the second for to start 2 elements below. Going from: for indice2 in range(indice*4, indice*4+4): To: for indice2 in range(indice*4+2, indice*4+4): #Notar no…
-
2
votes2
answers3297
viewsA: Iterate for with two variables
Yes you can iterate with two variables in python with for. For this you can use the function zip that returns a dropdown like this: for var1, var2 in zip(colecao1, colecao2): Which in your case…
-
0
votes1
answer68
viewsA: Validation of PHP file
Use the array as a hash table instead of a normal array. The way you are using, with the array_push, is getting all the indices sequential, something like this: [0] => "09999999", [1] =>…
-
5
votes1
answer275
viewsA: What’s faster: Stack or Heap allocation?
Efficiency The allocation in Stack is always much faster than the allocation in Heap, as a general rule only means esp, which is the current stack frame pointer in the amount of bytes desired,…
-
0
votes1
answer467
viewsA: Problem with fscanf
The reading being done in the patient file does not correspond to the form with the data are arranged in the same. In addition to the for is not inside the while because the { despite visually…
-
1
votes1
answer191
viewsA: Error when compiling C++ source code along with header file and member function file
If there is more than one file cpp, all have to be compiled at the same time, usually starting with what has the main: g++ fig03_17.cpp GradeBook.cpp However if you have enough files it will be more…
-
1
votes2
answers3167
viewsA: Operations with C++ matrices
You can do it all in one for calculating both things simultaneously. And have only one condition because when the i ends the j also ends. You can stay like this: int main() { int matriz[3][3] = {{1,…
-
1
votes1
answer1271
viewsA: Rename files in a directory using names already defined through PHP
If you have predefined names for the source and destination you can use a key array for the old name and value for the new name, and rename through the rename. Example: $caminhoBase =…
-
1
votes2
answers5011
viewsA: Delete a struct record
Corrections The code does present some error warnings of things that need to be corrected. One of them is the typedef who doesn’t have the name of the guy to be renamed: typedef struct cadastro{…
-
0
votes1
answer469
viewsA: How do I show some elements of an array following this criterion?
It is important to remember that in a form submission only the <checkbox> those that are marked/selected, those that are not even sent. If none is marked this key will not exist in…
-
1
votes1
answer180
viewsA: Referenceerror: boot is not defined
The error that appears to you is because the button clicks assignment code is done before the window.onload, this: for (var i=0; i<botao.length; i++) { botao[i].onclick = funcaoAuxiliar(i); }…
javascriptanswered Isac 24,736 -
0
votes2
answers532
viewsA: Change the execution of the onchange function from the select tag to an onclick function on a button
To literally answer the question you can put in the onclick in the <button> and call same function passing instead of this the corresponding item. As it is now on another label the this no…
javascriptanswered Isac 24,736 -
3
votes1
answer3265
viewsA: How to get input checkbox array value with jquery
The problem is that $("#funcoes_cursos input[name='cursos[]']") returns a list(array) of courses and not only one, so the .val() takes only the value of the first. In addition it is necessary to see…
-
1
votes1
answer89
viewsA: Relation between Python Arrays
To achieve this you can traverse the first array through the position and test whether the value is above 40 with a if. If you access the second array multiplying the position by 4 and accessing 4…
python-2.7answered Isac 24,736 -
0
votes1
answer1501
viewsA: How to use Boolean in Json
Starting from what you indicated in the comment, and if you’re using localStorage to store the value of autoLogin with true in localStorage, this is saved as string. To be more accurate as a…
-
0
votes1
answer337
viewsA: How do I read from position x to position y of a line in Node.js via the readFileSync function?
When a text encoding for reading is specified in readFileSync the function returns to the type string instead of being the buffer. For this reason you can read in the form of string with something…
-
0
votes2
answers37
viewsA: Error creating PHP connection
The method to define the sending type is setRequestMethod and not getRequestMethod how it was used, which should be changed right at the top of the connection to stay as follows: try{ url = new URL…
-
1
votes2
answers137
viewsA: Adjust the inline bootstrap form inside the rotary banner and adjust the fields
Since the <form> is with absolute positioning is not possible to center with margin: 150px auto. Instead you can apply left:50% and then pull to the left in half the size of the element with…
-
1
votes1
answer1566
viewsA: How to create a function that inserts elements from two double-chained circular lists
We should never ignore the compiler warnings, which help us realize potential problems in the code. Starting with these we see that missing return in some functions, such as inserirFim and in the…
-
1
votes1
answer34
viewsA: Extract Key Result
The correct way to use it would be: $resultado->ConsultarUsuarioResult->string[0] For the print_r that showed we see that it has an object: RESPOSTA = stdClass Object ( Who then has another…
-
2
votes1
answer213
viewsA: Calculations of skinfolds
The formula for body density lacked the coefficients as well as the square of X2. Remembering that the same is (by the pdf indicated): DC= 1,10938 - 0,0008267 (X2) + 0,0000016 (X2) 2 - 0,0002574…
-
3
votes1
answer548
viewsA: Increment dynamic input name with jquery
For this purpose one can construct a number outside the function: let num = 1; And use it inside and increase it. Then you can concatenate this number directly into the html built with: cols +=…
-
1
votes2
answers180
viewsA: How to ignore sentence and case in Java . startsWith
Java doesn’t really have a startsWith that ignores capital letters and minuscules as it has for the equals, which is the equalsIgnoreCase. However it is easy to find a logic that can do this by…
-
1
votes2
answers1674
viewsA: Multiply dynamic input values
To respond to this logic one can create a function for the two events, the blur (click out) and keyup when adding a new line, and for the added elements. This function only has to navigate the html…