Most voted "logic" questions
Use this tag when the question primarily involves logical sense in the development or processing of an information-based application that, related to each other, imply an objective within an established rule.
Learn more…376 questions
Sort by count of
-
4
votes2
answers183
viewsNested Vector Logic - C++
I have a problem with the following statement: Given a vector A with n real numbers, obtain another vector B, also with n real numbers, as follows: B[1] = 2*A[1] B[2] = 3*A[1] + 2*A[2] B[3] = 4*A[1]…
-
4
votes1
answer104
viewsDifference between [i] + 1 and [i + 1]
I have doubts about [i] + 1 and [i + 1], one increases position and the other content, correct? In relation to rating (*i)++, it is similar to which of the two cited above?…
-
4
votes1
answer792
viewsHow does the system of voting and rating by stars work?
I see the rating of the apps in the stores of Microsoft and Google and I can not understand the logic of both, I would like to make ratings by stars! But first I need to understand the logic of…
-
4
votes2
answers756
viewsProblems with calculating "TREE OF LIFE"
Good afternoon, I have a problem I need to do the following: Create a program, in C language, that calculates the size of the tree of life, after a certain number of growth cycles, taking into…
-
4
votes1
answer458
viewsHow to find the lowest value of a moon matrix?
I made this code that makes an Array (at least I think it’s doing) and then writes all the values in it. Obs: The values are random. I need to find the lowest matrix value, but the logic I’ve always…
-
4
votes1
answer192
viewsParallel Processing Routine C#
I would like to start a data processing method whenever I receive a String with START content through the Transceiver event.Receivelineeventhandler(); but this method will have a processing time as…
-
4
votes1
answer119
viewsError: in Builder cannot be Applied
I’m developing a simple calculator. I am checking if one of the fields is null open a Alertdialog, however I am with the error in Builder cannot be Applied, no this do Alertdialog.Builder. Can…
-
4
votes1
answer560
viewsC++ - Sort particular points of a rectangle in a vector?
I have a project in c++ where I should map regions of an image using the mouse click. The point is that I should get the mapping points in a specific storage order, as in the image below: my problem…
-
4
votes1
answer44
viewsWhere’s the mistake I can’t see?
What happens in the jeans_status and jeans_opcao it works a beauty more in the first if It doesn’t work, it goes into the if without checking whether the imagem_status == 1 and the imagem_opcao ==…
-
4
votes2
answers197
viewsWhen to use Factory in abstract classes?
Abstract classes are classes that cannot be instantiated and their implementation depends on other classes, but using the keyword Factory can "instantiate" an abstract class. So, how and when to use…
-
4
votes1
answer114
viewsRobo_feed routine of checking if loop giving dick in python
Robo_feed I’m new to python, I was looking to develop a robot that would take the last post of some news portals here in my region, With a survey I came to the conclusion that it would be easier to…
-
4
votes1
answer112
viewsLogic of these bit-by-bit operations
It’s been a long time since I wanted to start in the world of emulators, I decided to stop trying to make an emulator of a complex system and start with a very basic one, a CHIP-8 emulator, which is…
-
4
votes2
answers154
viewsIs it possible to condition an operator += in a ternary?
I have an empty object: obj = {} I’m trying to check if there’s a key op1 in that object. If there is I want to add the key and any value, getting like this: obj = { op1: 10 } // O valor 10 é…
-
3
votes1
answer667
viewsHours calculation
I need to calculate the exact time that a given record has to be analyzed. Each registration has a intermission where it can be analysed and, a maximum value in hours, referring to deadline for…
-
3
votes2
answers1093
viewsHow to assemble logic to read 2 files, compare them and extract values not found
I have 2 files .txt, one of them is a correct list of cities (contain all the cities of the country, written correctly) and the other, also a list of cities but with some wrong data (this list…
-
3
votes2
answers550
viewsLogic with date in excel
People, I am developing a spreadsheet to better control the production of the factory in which I work, I do not understand much of excel and I have a doubt that it may be simple to solve. Next, I…
-
3
votes3
answers441
viewsInteger conversation in the rounding account 0.1
echo (int) ((0.1 + 0.7) * 10 ) Isn’t that supposed to be eight? 0.1 + 0.7 = 0.8 * 10 = 8 You are returning me 7. because?
-
3
votes1
answer354
viewsHow to sum array data in json specified by date
array(10) { [0]=> array(4) { ["data"]=> string(10) "01/11/2015" ["valor"]=> int(50) ["intensidade"]=> float(37.5) ["carga"]=> int(35) } [1]=> array(4) { ["data"]=> string(10)…
-
3
votes1
answer2225
viewsAdjacent values
I need to create an algorithm that calculates the minimum distance value between the indexes of a matrix that contains adjacent values. But what are adjacent values someone could give me examples?…
-
3
votes1
answer49
viewsLogical error no for
Hi guys I’m trying to make a controlled loop for my program, so far it’s running normal only in the first round, in the second repeat it jumps the first pass of the go and starts in the second…
-
3
votes1
answer127
viewsBall movement in Volleyball game is too fast
For some time I’ve been developing a game of Volleyball in Java with Slick2d, but I’m having a very boring problem with the ball’s movement: I can’t get the ball to perform a parabola move (draw…
-
3
votes1
answer862
viewsError!!! You did not select the file to upload. Codeigniter
I have a problem uploading the image and registering it in my database. In my database I have a table called tbl_article where there is a when going to the image in question called artigo_image with…
-
3
votes2
answers76
viewsoverlapping tabs on foreach
I need the foreach to work properly : So that we have no doubt here this the normal code: <!-- Tab v2 --> <div class="tabs alternative"> <ul class="nav nav-tabs"> <li…
-
3
votes1
answer93
viewsHow to convert number into billions for a smaller comparison chain?
Imagine you have an exercise in the following aspect, I need to take from an array with random integers, the largest number that is between the intervals. For example, I have an array: array(2, 8,…
-
3
votes1
answer85
viewsWhy does x += y add the values in an iteration?
I don’t understand why this code r += v sum the values. I would like someone to explain to me why the output of this code: for c in range (0, 10): v = int(input("numero: ")) r += v…
-
3
votes2
answers73
viewsHow to find strings within an array
Good morning! I have the following array: const keys = ["idCard1", "idCard2", "idCard3", "oi", "idCard4"] I need to save in another array only what starts with the word "idCard", would be possible?…
-
3
votes3
answers5999
viewsseveral values for a column in Where
Is there any way to put several values for a column in WHERE? For example product A was replaced by product B, product 2933 for the 4044, product 2599 for 7845, and product 5987 by 9432. Example:…
-
3
votes2
answers280
viewsLoop is not repeating as it should
I am creating a code that reads the number typed by the user and, if it is from 1 to 10, it performs the tabulation, presenting value to value on the screen, besides allowing the user to choose…
-
3
votes2
answers1419
viewsCreate and assign loop variables For
How to make this logic within a loop FOR ? var G1 = $('#G1').text() var G2 = $('#G2').text() var G3 = $('#G3').text() console.log("NaN") console.log(G1+"\n"+G2+"\n"+G3) console.log(G1+G2+G3) G1 =…
-
3
votes3
answers13025
viewsSum of whole numbers from 1 to 100
I am trying to create an algorithm that adds the numbers of the interval 1-100. In addition the program prints each element of the sum and at the end the result. That is, 1 + 2 + 3 + 4 + 5 + 6...…
-
3
votes3
answers183
viewsif and logical connectives
I need to find the fewer number and the second to smallest number of five typed numbers. But this strange fact is happening: #Subtrair o menor numero encontrado do numero digitado dif1 = n1 - menor…
-
3
votes1
answer1651
viewsStore positives in one vector and negatives in another
Make an algorithm that reads a set of 30 integer numerical values and distributes them between two vectors, separating the positive numbers from the negative ones. Vectors must have 30 positions…
-
3
votes2
answers2007
viewsConcatenate Strings in C
Good afternoon, you guys! I have a problem in Strings using the C Language. The problem asks the user to enter a name, then to enter a special character, and finally how many times he wants the…
-
3
votes2
answers920
viewsRecursiveness: Compute the sum of the first positive odd values starting at 5
I’m doing some exercises on and I stopped on this a few days ago. I got to the following code: /** * Funcao: Soma dos primeiros valores ímpares positivos começando em 5. * @param quantidade -…
-
3
votes1
answer725
viewsLogic SELECT CASE WHEN
would like help in building the following logic: I have my main table and two other tables A and B, which have foreign key from the main. When an X column is filled in table A I need to classify my…
-
3
votes1
answer93
viewsA variable in my while is not adding up
I’m new to Python and I’m trying to make an old game I’ve tried in every way to fix this mistake and I can’t, so I ask for help from my consecrated people! My play function has a while that has to…
-
3
votes2
answers196
viewsPython 3 - Unexpected Flow Control when running IF/IF NOT or IF/ELSE
I’m new to Python, but I already have custom Java software. I would like to better understand why when trying to program a flow control using IF/ELSE or IF/IF NOT the whole block runs. Python code…
-
3
votes0
answers136
viewsProblem reading string(logic) characters - C
I was doing a program to register students, teachers and subjects in different structs. However I have to link them. For this I made a function only to do this task, but I can not solve a logic…
-
3
votes1
answer106
viewsConstant used within repeat loop
const body = document.querySelector("body"); const divElement = document.createElement("div"); divElement.setAttribute("id", "resultado"); body.appendChild(divElement); for(i = 1; i <= 20; i++) {…
-
3
votes2
answers852
viewsInsert elements in the correct position in an ordered list
I wonder why this code does not work for the exercise below, because when it comes to the values that will be intermediate in the list, they end up being reversed (the example I used to test if it…
-
3
votes1
answer177
viewsWeighted average with final examination
I need read 4 notes with weights of 2, 3, 4 and 1, respectively, for each of these notes and I must show this average accompanied by the message "Media: ". If this average is greater than or equal…
-
3
votes0
answers54
viewsAttempt to compare values from a list in a function does not generate the expected result
I have a function that receives a list and inside it a loop of repetition in order to go through all the positions and compare the value of that particular position with the value that comes by…
-
2
votes2
answers137
viewsSave temporary data to the array or query the database
It is necessary to check whether the user is allowed to view/edit data from a particular client. This verification occurs in almost all application operations. Currently when logging into the…
logicasked 10 years ago Filipe Moraes 8,737 -
2
votes2
answers86
viewsHow to create custom ordering?
I’m looking for a way to create a custom computer. Let’s say I have the following: var array = [ 1=>'A', 2=>'B', 3=>'C', 4=>'D', 5=>'E', 6=>'F', ] Now instead of ordering by the…
logicasked 9 years, 5 months ago RodrigoBorth 4,475 -
2
votes1
answer165
viewsTime calculation logged in to SQL
I have a system where user logs in and drops the tool several times a day during their work hours. I need to calculate the amount of time it was logged in: The columns LOGOUT and LOGIN are in…
-
2
votes1
answer579
viewsRationale: How does a friend localization app work?
I am studying mobile development and painted me a question: how works an app that locates friends on the map in real time? Example: An app that shows on the map where your friends are who also has…
-
2
votes0
answers246
viewsPath in C++ Binary Tree
I’m solving this exercise : http://br.spoj.com/problems/PREEMPOS/, but I do not know the logic of, from the result of the search in a tree of pre-order and order, arriving at the result of…
-
2
votes1
answer173
viewsLogic to make collection of books and movies using external data?
I was thinking of making a site that shows information from movies and books, for that I intend to take data from Aces like TMDB and Openlibrary. My idea is to join them in collections, for example…
-
2
votes2
answers193
viewsSegmentation fault in C: Adjacency structure representing graph
I need to create a program to read a graph and represent in an adjacency structure, however, my compiler is accusing Segmentation fault and I can’t figure out what might be causing it. It might help…
-
2
votes1
answer235
viewsDistance count between one element and each other in a list (Python)
I have a list that symbolizes a timeline: linha_tempo = [1107, 1107, 0, 1104, 1104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1106, 1106, 0, 0, 0,…