Posts by Isac • 24,736 points
820 posts
-
2
votes1
answer519
viewsA: error: assignement to Expression with array type
The problem is here: categoria='abaixo do peso'; For starters it has to be double quotes " instead of single quotes ', and also cannot be assigned directly as you are doing. To copy text to the…
-
1
votes1
answer960
viewsA: Open and close div with jQuery slideToggle feature
I start by saying I had some " missing in its example structure. As for the problem itself it is easier to solve by doing slideUp and slideDown manually. When you click on a widget slideUp to all,…
-
4
votes2
answers343
viewsA: String occurrence calculation in list - Python
A good way to count is to use the class Counter which already exists in collections for that purpose. This makes it necessary to import it before using: from collections import Counter After that…
-
3
votes3
answers1243
viewsA: Merge all values at the same array level, at the same level
Short Version There is yes: $resultado = array_map(null, $arr["A"], $arr["B"], $arr["C"]); or: array_unshift($arr, null); $resultado = call_user_func_array("array_map", $arr); Long Version There is…
-
1
votes1
answer41
viewsA: get directory
There are some ways to do what you want. Among the various show two. sprintf With sprintf can interpolate a string with whatever values you want. You first need to build the string in the form of…
-
1
votes2
answers101
viewsA: Change CSS with Jquery
A very simple solution is to use the function toggleClass, which puts the class in case it’s not there, or if it already is. For this reason you will switch between having the CSS of the class and…
-
1
votes1
answer1785
viewsA: Validate date of birth, so you can not register under 18 years (Javascript)
A simple solution to validate if the person is more or less 18 years old is to create a date with the same month and day, and with the year added up to 18. Then you just need to compare whether that…
-
3
votes1
answer2008
viewsA: Doubts regarding the use of memset and memcpy functions
It’s wrong to use memcpy and memset with data not char? memcpy can be applied in any type memset is actually wrong something other than the size of char. In this case it will not give the desired…
-
3
votes2
answers131
viewsA: Funcionameto Iterator
In the Rangedata class I create an iterator, but how it works? Your explanation is exactly what you do: I’ve read in the documentation that hasnext returns true if there is a next element in the…
-
2
votes1
answer60
viewsA: Infinite variable (javascript)
In the editor you mentioned, http://alpha.editor.p5js.org, the function draw is executed several times per second, whenever it is necessary to update the screen. Soon can not update the points in…
javascriptanswered Isac 24,736 -
3
votes2
answers190
viewsA: error: cannot Convert 'int*' to 'main()::class*' in assignment
Your code has several errors. My advice, and what I consider most important, is to pay close attention to the warnings and errors that the compiler gives. Even the warnings are mostly (if not almost…
-
4
votes2
answers377
viewsA: List separated by "-"
Just to get another alternative, you can use the function join of string to achieve its goal. It allows you to join several elements forming a new string with a separator defined by si: >>>…
-
2
votes2
answers65
viewsA: Segmentation Fault when removing list occurrences
You have 2 problems with your code: You’re not doing free of the nodes that are removed, and so has a memory leak. This problem despite not being notorious because it does not soon launches a…
-
1
votes2
answers906
viewsA: Email validation together with password with jQuery
Problem I start by saying that the regex you are using to validate the email: /^([\w-\.]+@@([\w-]+\.)+[\w-]{2,4})?$/ Has a @ the more, and for this reason does not work properly. Regardless of this…
-
2
votes3
answers100
viewsA: Printf does not print inside the while
The other answers already indicate which is the biggest problem you have, which is not using what is returned in the function insereL in order to connect the list, however, there is still another…
-
1
votes3
answers65
viewsA: How to use the output value
There’s a lot of things you need to fix first: number entrada = - This does not exist. To declare a variable you have to use one of the three possibilities: var, let or const. entrada =…
-
3
votes1
answer79
viewsA: How to have isset function using $queryString in php
For what you indicated in the comments you are using parse_url and parse_str to obtain the parameters of the query string of a given url. If you refer to the documentation you see that parse_str…
-
2
votes2
answers1611
viewsA: Word count using dictionary
Just as a complement to the answer you already have, I show another resolution alternative using Counter of Collections. This is a sub-dictionary class that counts the various elements received in…
-
1
votes2
answers17219
viewsA: Function that returns vector
Problem Let’s start by understanding the problem: float UK (int mat[4][4], float w[3]) { float *vetor[4]; ... //instruções que não são relevantes para perceber o problema return vetor; } Here are…
-
4
votes1
answer948
viewsA: Determine the key of a dictionary that contains the highest amount of values
Analyzing your code a little I see two things to point out: for i in aDict.keys(): - Here you are iterating over the keys, but then accessing the values in len(aDict[i]). It would be better to…
-
1
votes1
answer2803
viewsA: Compare a char vector?
"Can’t" compare with relational operators because the variables that represent the vectors are pointers to their first elements. For this reason when comparing for example with == is comparing…
-
2
votes1
answer1079
viewsA: Remove duplicated string characters if not a graph
I would like to start by saying that this regex does not cover 100% of your cases, but is correct in almost all of them. And I honestly don’t see much way to cover without complicating drastically…
-
0
votes1
answer37
viewsA: When I type withdrawal and place the amount higher than the balance the if is not working and barring this operation
The mistake was precisely that @Sveen has already commented. Your calculation of saque is not correct: saque= valor-saldo; If you have the saldo of 100 and valor of 50, your saque will be -50. For…
-
4
votes5
answers223
viewsA: Sum of hours greater than 24 hours
You already have several options to choose from, but I choose to make my contribution with a slightly different one, although similar to @Andreicoelho. Like his, my implementation also takes seconds…
-
1
votes1
answer671
viewsA: Sort matrix of n rows using the column value in C as a criterion
What’s going on is that there are little mistakes in fors and ifs, that I suspect are distractions: for (i = 0; i > (tam-1); i++){ //------------^ aqui tem de ser < aux = i; for (j = (i+1); j…
-
0
votes2
answers62
viewsA: js ul lis appearing a post a
To do this the most appropriate is to use setInterval to give the timing you are waiting for. In each time interval called by setInterval, passes to the next element (going back to 0 if it is in the…
-
5
votes1
answer67
viewsA: Doubt: Function of generators
You don’t need to know the background of generators to make a replica of enumerate, because this is simple. Its implementation would be something like: def my_enumerate(iterable, start=0): current =…
-
0
votes3
answers801
viewsA: Filter string array
Assuming the last name is the last name, you can divide the names with split(" ") and get the last with slice(-1) and check if that’s what you want: let nomes = ["Thiago Carvalho", "Renata…
javascriptanswered Isac 24,736 -
0
votes2
answers155
viewsA: Factor Hackerrank Solution - Using Algorithms Only
I start by saying that you don’t need to have 2 for to calculate frequencies: $ret = []; for ( $i = 0 ; $i < $n ; $i++ ){ $frequencia = 0; for ( $k = 0 ; $k < $n ; $k++) { Might as well do it…
-
3
votes1
answer72
viewsA: Class definition
When working with an Engine the first thing that matters is to see the documentation because it has important things to start, such as: guides examples tutorials first steps explanation of certain…
-
0
votes1
answer1943
viewsA: How to print a table-shaped array in nodejs on the console?
Javascript has no way for you to directly define the size of an array as it does in java with new int[4][4]. However you can start by defining the initial array with : new Array(tamanho) That…
-
2
votes1
answer677
viewsA: Create Chained Dynamic List
Let me start by saying that I’m not particularly fond of stuntmen typedefs for the same type being that one is pointer and the other is the normal structure: typedef celula Elem; typedef celula…
-
0
votes1
answer508
views -
1
votes1
answer102
viewsA: (JAVA) Error in foreach
You cannot remove the element with remove from the list as you travel with foreach as it invalidates the internally used iterator: for (Cliente cliente : clientes) { if…
-
4
votes3
answers359
viewsA: Numbers over 32, 64 bits
Complementing @Pedro’s response a little bit, there is currently no limit value for integers. You can see this by citation in the documentation: The sys.maxint Constant was Removed, Since there is…
-
3
votes2
answers166
viewsA: Real difference between Call and Apply methods
Unfortunately your example was not the best. I start by changing the example to show the arguments in full and not just your length: function scope() { console.log(this, JSON.stringify(arguments));…
javascriptanswered Isac 24,736 -
2
votes1
answer38
viewsA: container comparison
The reserved word was missing const at the end of the operator’s declaration ==: bool operator==(const Stack& e) const { // ^-----aqui ... } See in Ideone how this way already works…
-
1
votes1
answer56
viewsA: Counter from a value
To do what you want with the current code, you just need to change its function startCounting to interpret an input time and adjust the parameter start appropriately. I suggest you take the time of…
-
2
votes1
answer893
viewsA: Nodejs function, functioning
I start by saying that app.get is a normal function that takes two parameters: A path in the form of string and a callback. Soon you can view this function so: app.get(caminho, callback); In your…
-
1
votes1
answer85
viewsA: Because in this case I had to use freopen?
The problem is you already have the file open because you did fopen at the top: ptr_file=fopen("archive.txt", "r"); As you read characters from the file, you move the current position to the end.…
-
3
votes2
answers1487
viewsA: Dynamic writing effect of text
You already have a very good and practical response from @hugocsl about what libraries to use to achieve this, and also how to use them. However, in order to remain a reference as well, I show how I…
-
5
votes2
answers174
viewsA: Numerous if and Else conditions
Find the largest or smallest based on ifs and elses turns out to be very extensive and repetitive, and is not a scalable solution for a considerable amount of numbers. Moreover, the comparison I was…
-
0
votes1
answer61
viewsA: My program is not adding up the data it receives. Program in C
I start by saying that it should give relevance to indentation, because it’s more important than it looks when it’s starting. Quickly you find the code easier to read and organized, and the same for…
-
2
votes2
answers776
viewsA: Compare values in a list of tuples
To complement Miguel’s response, I show a way to implement the ordination he intends "in hand". It should be noted that in a real situation there is no need to do this, for various reasons, and its…
-
2
votes1
answer401
viewsA: How to insert a new div and stack them after clicking a button
To create copies of the elements you already have you can use the function cloneNode. Having the copies in hand just needs to put them in the right place, which would be the end of all the others…
-
7
votes2
answers11799
viewsA: What does float("Nan") and float("inf") mean in Python?
Infinity As already commented, float("inf") will create an infinite number: >>> float("inf") inf Which is actually equivalent to math.inf: >>> import math >>> math.inf inf…
-
1
votes3
answers206
viewsA: Dynamic Array - Android
If you need the array to be dynamic use an List, such as a ArrayList. According to the example you gave only the lines would need to be dynamic, in which case you could define the array as:…
-
5
votes2
answers473
viewsA: Regular expressions C++
What you want to get from string is very easy to obtain without regular expressions, as @rLinhares has already shown. If you wanted to do it with regular expressions, which I don’t recommend, you…
-
0
votes1
answer281
viewsA: Read end file to start
For the record, I see this as something merely funny and with no real application, yet it manages to do so using fseek and ftell. Start by positioning yourself at the end with fseek and with ftell…
-
0
votes1
answer88
viewsA: Storing in a vector without pressing ENTER at each insertion
If you are using c++ you can use a vector which is simple enough to add numbers as you read them. As for the reading itself you can do in several ways. One of the most direct is with stringstream.…