Posts by Isac • 24,736 points
820 posts
-
4
votes2
answers160
viewsA: I am unable to copy characters from one string to another
As already commented on the condition of for is not correct and should be: nome[i] != '\0' && nome[i] !='+' Which means, as long as I don’t get to the end and as long as I don’t get to one…
-
1
votes2
answers638
viewsA: While inside other While in Java
The logic you are using is too complicated, and in the end you have no reason to use 2 whiles with 2 flags of continua different. Instead it is preferable to validate each number individually and if…
-
2
votes1
answer14650
viewsA: I want to know how to limit the decimal place to c++ using Std
To define the number of decimal places to be written you must use setprecision and fixed: cout << fixed << setprecision(1); The number passed in setprecision indicates the number of…
-
6
votes1
answer671
viewsA: I want to check if the string contains only letters?
You may not use the isalpha how did you use: if(isalpha(dados.nome[tam])){ So it is using only in a character the 50 which is already outside the valid range in your case, which would be 0 to 49. So…
-
3
votes2
answers484
viewsA: How to create elements and add attributes with pure javascript?
The correct way to place attributes on an element with pure Javascript is setAttribute. In this case you will add the attribute if it does not exist or only update its value if it already exists. In…
javascriptanswered Isac 24,736 -
2
votes1
answer1348
viewsA: Evaluate ascending order with repeating structure
To compare whether the number is greater than itself is meaningless: if(num > num) Because a number will never be larger than itself. You want to actually compare it to the previous number, which…
-
1
votes2
answers236
viewsA: Promises in Nodejs
The problem begins with the fact that the 2 and the 4 be written asynchronously, so if you let it all roll normally they will be written at the end. I start by saying that this example is still…
-
1
votes1
answer112
viewsA: How to avoid repeating commands through a function?
A good way to avoid repeating these commands in the structure if else that has is using a dictionary with the respective text to be found in the command and function to use: commands = […
-
3
votes1
answer89
viewsA: $(this) in Arrow Function returns different element
This effect you see was one of the motivators for the creation of Arrow Functions. See some quotes from documentation in relation to that effect: Until Arrow functions, Every new Function defined…
-
1
votes2
answers55
viewsA: Generate dynamic borders
You can do as follows: No click starts by generating the same color for all Borders, whereas the ones that are 0px end up not being visible. Then finds the largest using Math.max on the values of…
-
0
votes3
answers169
viewsA: 2 Arrays in foreach from a form
The foreach supports only one collection and not two. However you can do what you want using array_combine combining names and quantities into a single array, transforming it into an associative…
-
1
votes1
answer43
viewsA: Check some array values within another array
I suggest using the function array_intersect which gives you the interjection of two arrays. For the case in question if the intersection results in the input array then all elements of $required…
-
0
votes2
answers3052
viewsA: Repeat a CSS animation every time I click the button (with Javascript)
You can first put the animation with nothing: this.style.animation = ''; And then apply the animation again. The detail is that you have to give a short interval of time for the change to be…
-
1
votes1
answer1288
viewsA: I want to make a decimal to binary converter without using itoa() or vectors in C
It turns out that since it is storing the binary representation in an integer, it quickly passes the capacity of representation of it and generates a overflow. Note the number 1200 in binary:…
-
8
votes2
answers1582
viewsA: What is the difference in the syntax ptr = (int*) malloc (sizeof(int)) and ptr = malloc (sizeof(int))?
Both instructions do the same, and the end result is the same, differing only in writing and portability details. Remember that the function malloc return a void*, or a generic type pointer, and you…
-
1
votes2
answers278
viewsA: Javascript.push() inserts variable instead of variable value
Whenever you’re building an object you have to define key and value pairs. Where the key is actually a name, the name of the field to which you want to associate the value. let pessoa1 = { nome:…
javascriptanswered Isac 24,736 -
3
votes4
answers2906
viewsA: How to get the highest value in an array with Javascript?
The problem lies in the logic you are using. You can not build the largest only based on the two elements you analyze, as those that have been analyzed backwards will be disregarded. I put your code…
javascriptanswered Isac 24,736 -
2
votes1
answer355
views -
2
votes3
answers1276
viewsA: code to return divisors and compare common ones
Taking advantage of the function you have to calculate the dividers, you are a little short to complete the problem. In order to be able to re-use the function that has the best option is to…
-
1
votes1
answer1139
viewsA: How to distribute the items of a horizontal list independently of their quantity?
This is very simple to do using display:flex. You need to apply this style rule to the parent element that you want to distribute, and then you define how they align with the rule justify-content.…
-
0
votes3
answers106
viewsA: Find the size of the largest sequence of # in an array. JAVA
I suggest a different and more linear approach, still assuming a specific demand for rows and columns. private int obterMaiorAtualizado(int repeticoes, int maior){ return repeticoes > maior ?…
-
6
votes4
answers103
viewsA: How to avoid value repeats in this code?
For the second case how each letter is inside a string can traverse the strings through Object.keys and see if it has the letter indexOf. If found returns the associated value. Example: function…
-
1
votes1
answer421
viewsA: How to dynamically allocate an array using a pointer pointer in a void function
Looking at the compiler warnings we see that missing include library <string.h> which is where the strlen. Analyzing a little the memory allocations you made: void lerArquivo(char *alfabeto,…
-
1
votes1
answer388
viewsA: How to clear search results in a list after clicking a button?
Failed to implement the code for the reset button that puts the results all over again: $("#rst").on("click", function(){ $("#body-post li").css("display", "block"); //mostrar tudo…
-
2
votes1
answer2029
viewsA: Error "No match for Operator <<" in C++
This error means that the compiler does not know how to write the object File on the given stream. This is because somewhere in your code you have something like: Filme f; cout << f; How you…
-
2
votes1
answer31
viewsA: C programming using Codeblocks from giving error in the programming below
The ternary operator may produce only one value and not an instruction. Soon instead of: num1 < num2 ? printf("Sim/n") : printf("Nao/n"); num1 < num2 ? resposta = 10 : resposta = -10; Must be:…
-
4
votes2
answers897
viewsA: Separate equal values in an array
Make a function to group: function agrupar($array, $campoAgrupar) { $resultado = array(); foreach($array as $valor) { $resultado[$valor[$campoAgrupar]][] = $valor; } return $resultado; } Grouping by…
-
3
votes2
answers2211
viewsA: How to change the title of an Activity?
The method to change the title is setTitle in fact, but of Activity and not of Window Once your class extends Activity just call directly: protected void onCreate(Bundle savedInstanceState) {…
-
4
votes1
answer241
viewsA: Object doesn’t support Property or method 'prepend'
The method prepend which you have specified is not supported in Edge browser or IE. This is something you can confirm in the documentation compatibility section However, you may use polyfill that…
-
0
votes2
answers708
viewsA: I want to view all json array records
The problem has already been explained by @dvd, which is the fact that the variable html have to stay before the forEach and only modified inside. However for the case you have it becomes much…
-
0
votes2
answers1796
viewsA: Formulario Email React
The ideal is to use status. It starts with the state so that the message is not visible. The most appropriate place to do this is in the builder that has not yet defined: export default class…
-
1
votes1
answer35
viewsA: How do I change the reservation on mobile
What you are trying to do is basically transpose a 2D array. The problem is that in your case it is not even a 2D array but an array of strings which adds difficulty to the problem. In addition to…
-
3
votes2
answers232
viewsA: Sum json object with pure js
If you want to replace all values of json2 in json1 then you just need to go through your keys with Object.keys and apply the value to each key. This way the ones that exist will be replaced and the…
javascriptanswered Isac 24,736 -
1
votes1
answer261
viewsA: How to print a list array (a pointer to a list)
List array initialization is missing: list<int> *adjV = new list<int>[3]; With this initialization you already get the expected result. However now you can take advantage and turn…
-
1
votes1
answer163
viewsA: how do I save a dynamically allocated vector and return as a pointer in the function?
There are quite a few errors in the program, but I start by answering the question directly. Vector return To return a dynamically allocated vector, simply change its return type and use the keyword…
-
1
votes1
answer373
viewsA: ASCII characters and table
Actually the program is not setting values for when it is not a letter, thus picking the default value that is in the vector y. Change your for for: for(i = 0; i<qnt; i++) { if (((x[i]>=65)…
-
2
votes1
answer111
viewsA: Jquery . after()
The selector ".input-files" hits 3 <div class="input-files"> of its original html, for this reason it adds a new element after each one. Instead you can only catch the last one by adding to…
-
2
votes1
answer150
viewsA: Simulate area of action of points in matplotlib
Instead of building the circle on a point directly: x0 = 10 y0 = 10 circle = plt.Circle((x0, y0), r0, color='r', fill=False) plt.gca().add_artist(circle) You must do it for all of them by going…
-
1
votes1
answer48
viewsA: Doubt with excel files
The problem is that the csv file has more than just numbers that it won’t be able to read with %d. Although you can try to change your algorithm for this case, for example with sscanf I think it’s…
-
3
votes3
answers73
viewsA: Javascript object always being created in growing order
The order of insertion in the object is not guaranteed by the specification. However, if you use a Map this is already true. This provides you the same functionality ensuring the insertion order,…
javascriptanswered Isac 24,736 -
5
votes3
answers1627
viewsA: Nested lists in python
You can solve it using recursion. Creates a function to print the list, and whenever each element in that list is another list calls back the same function on that element. To know if an element is…
-
0
votes3
answers235
viewsA: arrays equality in Java Script
The problem has already been explained by @Pantera, but to stay as reference to future readers I leave here another way to create a copy of the array using concat: let xau = oi.concat() The concat…
-
2
votes3
answers108
viewsA: My input checkbox does not support Javascript
Another alternative is every time you click on an item deselect all others. You can use filter to remove only the element you have, and then apply checked = false the ones left: Example: const boxes…
-
0
votes1
answer26
viewsA: Delete the last number I typed
The problem actually has to do with how you structured the program. Within the while is reading the number and adds it to the list regardless of its value: while Numero>0: Numero =…
-
1
votes2
answers2574
viewsA: Is there a command to finish the program in Python?
Python actually has a way to finish the program execution by doing: sys.exit(0) Assuming you previously included the library sys: import sys In your case it would look like this: import sys #…
-
1
votes2
answers40
viewsA: Get a word from a variable that has more than one word, with jQuery
To complement the already good @dvd response, I put here another solution using filter and indexOf and toLowerCase. First approach with filter and indexOf Using the above two functions to filter…
-
1
votes4
answers244
viewsA: Set a range in the execution of each for loop
Here I show a solution similar to @dvd but using let in the for that ends up capturing the right context not needing an extra function around the setTimeout. This is related to closures and with the…
-
2
votes1
answer151
viewsA: How can I open a file in a void function?
In C the parameters are passed by copy. If you want to change the value in the function you can pass the address of the value you want to change instead of the value itself. In your case you would…
-
4
votes3
answers1407
viewsA: How to transform an Object Array into a Simple Array? Javascript
The simplest is to use the function map array, which was precisely for this type of situations that was created. This allows you to obtain a new array based on a current array transformation. In…
-
3
votes1
answer175
viewsA: Dynamic allocation giving problem in c++
In fact you have a very subtle little error in your program, and it is in the memory allocation of the two-dimensional array: arr = (int **) malloc(sizeof(int)*arrqtd); Which should be arr = (int…