Posts by Isac • 24,736 points
820 posts
-
3
votes3
answers2456
viewsA: How to organize items from an array in alphabetical order?
If each block between @ of the item means something so it is easier to start by separating these elements for an array with explode: foreach ($array as $chave => $valor){ $array[$chave] =…
-
1
votes2
answers315
viewsA: Execute method that is inside the "onclick" event
Actually the problem is what you assumed was x.onclick Note that onclick in x is an object ... The onclick in x was actually with a function, something that can prove with the operator typeof var x…
javascriptanswered Isac 24,736 -
3
votes2
answers601
viewsA: What is the difference between map() and lenght()?
The map receives a function that is applied to each element, and the return of that function builds all new elements mapped. The function map that indicated could have been written like this…
-
2
votes2
answers243
viewsA: Error concatenating string in jquery
I advise to use Template literals that ends up being much easier to build the strings you want. In your case it would look like this: linha += `<td><a href="#"…
-
2
votes1
answer1186
viewsA: How to find a name with struct
The search you have is correct but the way it shows the value found is not, because it has a printf for each presente analyzing. Instead what you want to do is to store in a variable if you found…
-
1
votes1
answer83
viewsA: Stack insertion vector returning all zero
If you want to add multiple elements in a row to the stack at the expense of one for does not need to transform each cell element into an array, and can maintain the old structure it had: struct…
-
1
votes1
answer45
viewsA: Calculate the total of a table column based on the checkbox by taking only the selected ones
To facilitate the process I chose to add the class check at checkbox and a class total in the columns of totals. For each checkbox the logic to apply is: Set the event change In this event find all…
-
2
votes1
answer215
viewsA: Difference between . Closest() and . find()
Closest Search in your ancestors by items that match the selector passed, as specified. That is, searches in items that are up. Consider the following structure: <table> <tr>…
-
2
votes2
answers4011
viewsA: Show and IDE jquery effect
If you want to show the Box_editor after each .icon-edita then you must use next() to get to the front element, which is the box, and in that do show. The way it is with $(".Box_editor").show( ends…
-
5
votes1
answer313
viewsA: Loop for reading text file reads the last line twice
The problem is in the test of while: while(!feof(arq)){ That actually tests whether any reading has been made beyond the end, like the documentation indicates This Indicator is generally set by a…
-
1
votes5
answers1024
viewsA: How to get last position of an ID in the array
A simple solution is to create the last coordinates as you add new ones with a dictionary, using the id as key for not having repeated ids. All you need to do is change your method…
-
0
votes1
answer322
viewsA: Write to C files
The problem is how you are using the parameter argv in his for: for(cont=1; cont <= *argv[3]; cont++) { -----------------------^ aqui argv is actually an array of strings that is normally…
-
2
votes2
answers51
viewsA: Can anyone explain to me what this code does line by line?
The code starts by defining the variable x as whole with the value 5 and calls the function segundo with the memory address of the variable x: int main() { int x = 5; segundo(&x); In this…
-
0
votes2
answers935
viewsA: Compare values of an array with values of an object
Assuming that your convert the numbers again into String refers turns them back into the original letters based on the number, you can use the method find array, starting from an array of keys with…
javascriptanswered Isac 24,736 -
1
votes3
answers95
viewsA: how could I use instead of passing an id, passing a Class in JQUERY?
The code you have for click events is a little strange and should be: $('#submit1').click(function () { alert('Submit 1 clicked'); }); $('#submit2').click(function () { alert('Submit 2 clicked');…
-
1
votes2
answers190
viewsA: Read an integer value from a file
A very simple solution is to use fscanf and check how many values have been read, and finish when not reading the ones that matter: int main() { int valor; FILE *arquivo = fopen("arquivo.txt", "r");…
-
3
votes1
answer912
viewsA: Segmentation fault (core dumped) when accessing String
There are some things you need to get right: When does printf with %s is supposed to pass a pointer as parameter, which was something that was missing in: printf("%s\n", link[i]); Since you are…
-
2
votes2
answers5930
viewsA: List input
The range(0,10) who has will ask 10 numbers but if one puts a repeated number, one will end up not asking for enough numbers because the repeated numbers have been discarded. It is better to…
-
1
votes1
answer1722
viewsA: How to move a div with the JQUERY mouse?
The Jquery UI library has functions to move and resize. For it it is necessary to first include the normal Jquery. Move To move a div or any other html element needs to use the function draggable…
-
1
votes2
answers74
viewsA: What is the easiest way to classify DOM elements using pure Javascript?
Assuming you have an array of built products, which are the ones shown on the page, you can use the function Sort to apply an ordering by any criterion you wish. This function receives a comparison…
javascriptanswered Isac 24,736 -
1
votes1
answer191
viewsA: Exercise URI 1012 - Wrong Answer 20%
The std::fixed indicates that the following scripts will be done with a fixed point notation. The number of digits shown after the comma is defined with setprecision. If you want to show 3 digits…
-
0
votes1
answer77
viewsA: Leave dynamic code in an array filter
Even considering only cats, the logic you have is complex and with a mistake when you pass the amount of existing cats: for (let i = 0; i <= clickCount; i++) { for (let j = 0; j < i; j++) {…
javascriptanswered Isac 24,736 -
3
votes2
answers1187
viewsA: Meaning of two asterisks in function call
The meaning of ** I understand, my doubt is why it was used in that specific function The situation here is that the function InserirInicio has to be able to modify its own Nodo that exists in the…
-
4
votes1
answer66
viewsA: Why doesn’t this redacted code work the same as the original?
and in C++ gives 50. Not really, because the program has an undetermined behavior so it can give any value as a result, something that can confirm here The problem is here: size_t len =…
-
1
votes1
answer193
viewsA: Magic square in android
A flexible and organized way of finding sums is by using two-dimensional arrays representing a grid. For this it will be necessary to take in each value of EdiText and interpret as whole with…
-
7
votes1
answer839
viewsA: JS calculator: unexpected results
The problem is how to start the text that corresponds to the result calculation: function resultado() { var result = 0; //<--aqui for (var i=0;i<array.length;i++) { result += array[i]; }…
javascriptanswered Isac 24,736 -
1
votes2
answers337
viewsA: detect repeated char in c++ string
If you want to find parenthesis with the find of string is perfectly possible, and similar to what I was doing: std::string texto ("Na(CO5(Pt"); std::size_t posicao = texto.find("("); if…
-
3
votes1
answer786
viewsA: How to trade two non-consecutive knots on a doubly chained list?
In your code changes to B->prox and A->ant are not correct: A->ant = anteriorB; B->prox = proximoA; For the former of A will become the B, and the next of B will become the A. In…
-
2
votes2
answers1301
viewsA: Sum 2 arrays with equal indices
If you want something simple you can base it on array_map to map an array of products in their names and then search the product with array_search. If you find the product updates the quantity,…
-
4
votes1
answer82
viewsA: How to improve this code
Since you have a JSON the ideal is to navigate all the information through the JSON parser methods instead of using regexs and/or splits. Using org.json The most direct way to obtain temperature,…
-
1
votes1
answer80
viewsA: Error reading values for a dynamically allocated matrix
The problem is the return of the function alocar: int ** alocar(){ int ** matriz; int i; matriz = (int **) malloc(3 * sizeof(int *)); for(i = 0; i < 3; i++) matriz[i] = (int *) malloc(3 *…
-
1
votes1
answer529
viewsA: histogram of a c++ phrase
The comparison you have in the for: if(frase[num] <= alfabeto[num])az++; It doesn’t count the letters correctly, because it’s only comparing if the letter you have is smaller than the letter you…
-
1
votes2
answers5286
viewsA: Put the input data into a list
The default start value of range is 0 soon make range(0,10) corresponds to make range(10) which is simpler. If you just want to read the various values, you can do it in a pythonic way using list…
python-3.xanswered Isac 24,736 -
2
votes1
answer2132
viewsA: How to pass an file . txt to a function
The function that receives the file must receive a parameter of type FILE*, and will usually be of the type void unless you want to return a specific value to the main. In the main when calling the…
-
3
votes2
answers7869
viewsA: Indentation of code C
Indentation You can indent in Codeblocks by accessing: Plugins > Source code Formatter(Astyle) Shortcuts You can also associate a shortcut to indentation via: Settings > Editor > Keyboard…
-
1
votes1
answer1103
viewsA: How to remove a specific item from a double-chained list?
Has two code problems: if (primeiro.elemento.equals(item)) { primeiro = primeiro.proximo; primeiro.anterior = null; //<-- esta linha (1) return true; } ... while (n.proximo != null) { if…
-
1
votes2
answers120
viewsA: Collecting data from an array
If you can only use two-dimensional arrays of Strings your solution is on the right path, but missing the calculations of the points. If it is all a String then it will be necessary to interpret the…
-
7
votes1
answer1909
views -
1
votes1
answer40
viewsA: Failure to pass html menu to Cakephp
The selector you are using to build the buttons: const botoes = [...document.querySelectorAll("li")]; It is very broad and ends up hitting more elements than intended. One simple way to solve it is…
-
1
votes2
answers151
viewsA: Help in code printing of repeated characters
Your solution came close to working. You just need to consider occurrences with more than 1 and disregard letters that have already been processed. There are many possibilities to solve the already…
-
1
votes2
answers57
viewsA: NAN as a result of a function
The input values are being obtained before the user even enters them. You should only get them when the button is clicked ie in the event of click. This refers to the .value and not specifically to…
javascriptanswered Isac 24,736 -
0
votes1
answer176
viewsA: Binary tree of search
Its function insere has the missing return, which does not allow you to correctly build the tree. The value to return has to be p: Arvore * insere(Arvore * p, int key){ ... return p; //falta este…
-
1
votes1
answer269
viewsA: error: invalid Conversion from 'my_type*' to 'int' [-fpermissive]
Note the method signature: void BrainGraph::addBlock( BlockGraph block, int sickcells ) Wait a BlockGraph when a BlockGraph*: BlockGraph* block; ... brain->addBlock(block, sickcells ); If you…
-
2
votes1
answer2607
viewsA: How to remove duplicate elements from a C list?
Problems There are some flaws in the logic that is implemented: You are not removing the various repeated successively as you only use the a at the end of the second for Can’t do free(p) and then…
-
2
votes1
answer1026
viewsA: Submit a single div Reload post
As stated in the comments do not load, instead implement the Handler successful with done or success and in that Handler update the html of <div> who matters. Example: $("#issuedButton,…
-
0
votes3
answers1470
viewsA: Hide DIV when loading the tab according to select
If you need to run something when the page loads and you are using Jquery use the default in Jquery: $(function() { //código a executar quando todos os elementos estão carregados }); To apply the…
-
3
votes2
answers1297
viewsA: Problem with gets and fgets
I suggest using always fgets, since it is something you are already using, and ensures that your program is never susceptible to Buffer Overflows. Even when you have to read a whole like in case a…
-
2
votes2
answers37
viewsA: How to set alternately the background color of sections of a CSS page?
There are specific selectors to catch even and odd elements, which allow you to do what you want with ease. You can start by formatting all elements normally and overwrite formatting for pairs with…
-
2
votes3
answers108
viewsA: Decrease the lines of code by maintaining the function of getElementByID?
One of the ways to reduce a lot is to store the elements brought by getElementById variables outside the functions and only use them within the functions. This can also make your code more efficient…
-
0
votes1
answer624
viewsA: Change variable value of Orange Session
As you are doing already changes the user name in the session. If you want to change/set only the name you can do: session(['id_usuario' => 'novo nome do usuario aqui']); If you are reading the…