Posts by Maniero • 444,682 points
6,921 posts
-
2
votes1
answer68
viewsA: Logic expression that controls repetition
The code is a little confusing and makes a mistake that I always see around. A beginner commits by not knowing and the expert commits because he thinks he can’t use any form of goto, then he gets…
-
3
votes2
answers71
viewsA: How do I declare a ternary operation for it to show on an HTML page?
You believe too much in variables and interestingly in this case the lack of one was the problem. You made the expression and did not keep anywhere the result of it. Then tried to use the average…
-
7
votes1
answer241
viewsA: What is the most efficient way to make string literals not appear in compiled code?
Not putting on executable. The only way to prevent a string Do not be caught by any form of reverse engineering is it not existing. If you need the data at any time within the application, whether…
-
5
votes2
answers257
views -
4
votes3
answers1958
viewsA: How to print list elements in reverse order?
If you can use something ready have at least two techniques: lista = [] while True: i = int(input('Digite um número: ')) if i < 1: break lista.append(i) for i in lista[::-1]: print(i) for i in…
-
3
votes1
answer82
viewsA: Pascal’s triangle is in infinity
The main problem is that it is incrementing where it should place the end condition of the loop and is placing the condition where action should be executed at each step of the loop. Reversing this…
-
5
votes1
answer95
viewsA: What is the correct way to insert a necessary data into a constructor in PHP?
You cannot put the parameter name. PHP does not have the argument engine named as other languages do. If you saw this in a PHP video, it’s already a good indication that it’s a bad source, like a…
-
5
votes1
answer140
viewsA: Is the purpose of the inheritance reuse?
That’s what I always say, object orientation is poorly defined and depends on who defines (see). You will find that heritage is to be reused in various places and I am not talking about random…
-
3
votes1
answer57
viewsA: Display negative days in calculation between dates
The biggest problem seems to be the adopted formula. I did not use the function abs() that removes the signal. If the result is expired it is negative, with this function any negative number turns…
-
1
votes1
answer59
viewsA: What happens when using namespace within a namespace?
The second code works and will access the value of k. The using ends up being a kind of include within the scope, even if it does not function as #include, which even becomes less useful in C++20,…
-
2
votes1
answer91
viewsA: Return an instance of the same class in Static Function
To call static members you should always use ::, not only use in one place, then the correct code would be: Router::get()::name('string'); Obviously it is possible to return the class itself in a…
-
3
votes2
answers197
viewsA: When to use Factory in abstract classes?
You know that the abstract class cannot be instantiated, but it can have a constructor as long as it constructs an object of a concrete class, and of course, the correct thing is that this object is…
-
2
votes2
answers51
viewsA: How to sort a table in MYSQL, along with the query command
If the column calls ano: SELECT * FROM alunos WHERE nome_aluno LIKE '%$pesquisar%' LIMIT 5 ORDER BY ano The ORDER BY is the clause you sort in the specified order. If you don’t have a suitable index…
-
2
votes1
answer195
viewsA: Sentence while - not true... understanding logic
The program stops because its code determined it. A first place it stops because it completed what it had to do. It can only conclude after it comes out of the loop and the condition of the while is…
-
2
votes3
answers145
viewsA: Same codes, different outputs
The question has a clearly wrong premise, they are not equal codes, they are quite different. Any change in the code, however minimal, may produce different results. The first value starts with 1…
-
7
votes2
answers154
views -
2
votes2
answers71
viewsA: Object array gives error when I try to access an element of it
You declared the array with capacity for one element, then tried to fill 2 elements. The second gives error. Maybe you’re thinking the one in the statement of the array indicates which is the last…
-
1
votes1
answer53
viewsA: Inclusion of`final` by Eclipse after saving file
Certainly he did not do it in random variables, he did it where he could do it and it looked better (if the algorithm and criterion he uses is good). He must have turned on an eclipse mechanism in…
-
1
votes1
answer44
viewsA: C# deserializar Enum that does not exist
You can read What good is a builder?. It shows that the constructor serves to create the object in a valid state. If there is no data to be used then the object cannot be created. If you were to…
-
6
votes1
answer516
viewsA: Difference between using struct and class to create an object
There are some wrong questions and assumptions there. And I will disregard the wrong Java syntax and everything is out of pattern. You cannot make an assessment of the differences just by syntax,…
-
1
votes1
answer455
viewsA: Problem turning string into int: "error: no matching Function for call to stoi"
You do not need to use this function. What returns in var1[i] is a character, so neither could use this function that expects a string. I put in the code the simplest way to convert a character into…
-
2
votes1
answer95
viewsA: Why does "var" force type inference?
Let’s see what kind he inferred and what kind he caught when he was explicit: import 'dart:io'; import 'dart:mirrors'; void main() { Map a = { '6' : 6, }; var b = { '6' : 6, };…
-
6
votes2
answers140
viewsA: How do I access getters and sub-class setters?
In essence does not access, at least not directly and correctly. If you have a field (attribute is the wrong term) or methods getter/Setter unique to the sub class it can only be accessed on objects…
-
12
votes6
answers623
viewsA: What is the reason for the application of the concept LIFO (Last In, First Out)?
The pure application of this concept of UEPS (Last In, First Out) does not bring an inherent obvious advantage. Its application in a specific way can be very advantageous. The concept itself is too…
computer-scienceanswered Maniero 444,682 -
6
votes6
answers491
viewsA: Optimize code in Python
The two answers gave certain codes, but I’ll give my version because I hate it when it violates the DRY, even in small code because then one learns to always do so, so without repeating relevant…
-
7
votes1
answer67
viewsA: What is the difference between sanitizers and validators in PHP
As the name says, FILTER_SANITIZE cleans the data by removing unwanted characters according to the criteria of that chosen sanitization, but it does not indicate whether it is valid or not. He moves…
-
2
votes1
answer65
viewsA: A data request from another data must respond with 404 or an empty array?
It depends on the semantics you want to give. E there are controversies as to that. Some people categorically state one thing, others are more thoughtful. So don’t consider this an answer that says…
-
5
votes2
answers767
viewsA: Compare String Elements in C
I’ll give you a few things to learn how to code correctly: Do not use gets(), this function is problematic and is considered obsolete. fgets() is the correct path. I protected the memory access by…
-
4
votes1
answer82
viewsA: I want to put 2 exceptions for my program validate data
I think this is what you want to do: try: a = int(input(a)) if a > 0 and a < 7: print ("o valor deve ser entre 1 e 6") except ValueError: print ("Escolha uma opção válida") Behold working in…
-
10
votes2
answers482
viewsA: What would be the "identity" of an object?
TL; DR It is the way to determine what the object is and in some cases distinguish one object from the other. Where it is most used is to determine whether it is the same object or another. It’s how…
-
2
votes1
answer123
viewsA: The program is not recognizing whole number as such
Python, its standard functions, detects impossible conversions through an exception mechanism, so you have to capture the exception to identify that there was error, thus: try: a = int(input("insira…
-
3
votes1
answer112
viewsA: How does Python identify which commands are inside if?
In C we have how to inform the size, or how far the function is present This statement is wrong. This is nothing to do with function this is a block of commands. A function always has a block of…
-
11
votes2
answers286
viewsA: Why does the exchange of values via de-structuring not work if we do not use semicolons?
Javascript has chosen to specify in the language that the ;, which means the end of a statement, could be optional in code. Contrary to what many think, it’s not that you don’t need the semicolon,…
-
4
votes1
answer554
viewsA: Calculation of salary needs to limit houses
There are some problems in this code. Besides being too complex, it does not do what the statement asks and produces the correct result. The issue of formatting is just a point that won’t make it…
-
6
votes2
answers295
views -
12
votes2
answers253
viewsA: Why is it good practice to generate unique user code?
For those who have no experience, these codes are usually classificatory and each character means something specific, a grouping, a way to use, it is as if they were tags. It may seem but they are…
-
5
votes1
answer164
viewsA: What does this code mean/do?
My suggestion is to learn to program step by step, to understand each mechanism of language, to go structurally forming its knowledge. I’ve never seen anyone (must exist somewhere) who could learn…
-
7
votes2
answers158
viewsA: What happens to memory when "realloc()" reallocates a memory block to a value less than the original?
what happens to the other 7 ints, they will be released from memory by the function realloc() or the memory will leak? It will be released. Technically the memory will not leak, but nothing…
-
8
votes1
answer151
viewsA: How to avoid repeating "using" in ASP.NET MVC?
You are not repeating :) I imagine you want not to use in others actions, right? That being the question maybe it’s not just the using. It itself is not the problem, and the solution just to…
-
17
votes5
answers639
viewsA: Complete number with "zeros" until the total size is 9!
Keeping the idea of doing with text does not need a loop: let number = 18; console.log(parseInt((number.toString() + '000000000').substring(0, 8))); number = 678;…
-
11
votes2
answers4166
viewsA: What is the difference between the map() and flatMap() functions of Java 8?
Both take the elements of one stream data (usually a solution such as array or ArrayList) and each element will have an action to be defined below. The difference that flatMap() can do this in…
-
4
votes4
answers491
views -
1
votes2
answers488
viewsA: Voidcallback x Function what’s the difference?
There is no difference, it is only a simple way to use the type, is the library using a language resource to facilitate the use, the typedef does not add functionality, it just generates the same…
-
8
votes2
answers586
viewsA: What does #noqa in Python mean?
How do we know that not even the creator of language knows? :P :D Jokes aside, for the Python language itself means nothing, it is even more specific than Python. As can be seen in link above is…
-
6
votes1
answer65
viewsA: Why does Std::Ceil produce different results for float and double?
These types are not accurate, so you get approximate values. If you want accuracy you cannot use either. Who uses these types of data should know that the values are approximate, never exact. The…
-
8
votes1
answer77
viewsA: Confirmation code
The code is complicating what you don’t need: import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String resp = " "; while…
-
2
votes2
answers991
viewsA: Transform matrix into vector
I wasn’t going to answer that, but anyone who knows me knows there’s a case I can’t help. See comment because I find this kind of question complicated but already has an answer. public class Program…
-
3
votes2
answers367
views -
2
votes1
answer58
viewsA: Error in string formatting
If you have a variable in a place that expects a literal needs to say it’s a variable, then just as you say it’s an expression to be interpolated and not a text literal, you have to say it’s an…
-
4
votes1
answer343
viewsA: Difference between ACL and RBAC access control types?
First: I researched to give a more informed answer and I concluded that some people disagree at least with the details of what is each thing, it is not easy to find a formal definition, and this is…