Most voted "algorithm" questions
An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when the problem is related to the design of an algorithm. Always use specific algorithm tags when the question is more directed to a specific type of algorithm.
Learn more…723 questions
Sort by count of
-
-1
votes1
answer47
viewsSum function returns zero
By the time the input is all ok with the information, but in the output only gives the result 0 and do not know what else to do, already I moved and I reworked the whole code. The idea is that in a…
-
-1
votes1
answer33
viewsMethod/Algorithm for fetching an ASP.NET MVC date
I have the following problem: I’m trying to get a date. I just can’t figure out an algorithm for this. I have a class called RequisicaoDeVeiculo, this class has the attribute DataEHoraDoServico, and…
-
-1
votes1
answer67
viewsC# - Algorithms - For loop - Logic - Using previous value of a variable and current value of another variable
DOTNET FIDDLE Editing The following calculations correspond to actuarial calculation variables. The ages from "present age" to the age of 120 years run through the probabilities of a person’s death…
-
-1
votes2
answers390
viewsReceive an integer number in the input, calculate and print the sum of the odd digits of this number in the output
I saw a similar doubt and he used this code, but in my case I need him to add up only the odd numbers he gets. For example, when typing 123, instead of adding up 1+2+3 it should add up 1+3 only. How…
-
-1
votes2
answers260
viewsAlgorithm that creates a Python queue
Hello, I would like to create an algorithm but I don’t know much how to start it... It would be to write a program to create a queue, represented by a list, and present to the user the options to…
-
-1
votes1
answer88
viewserror: EOF when Reading a line
I need to round the notes to the next multiple of 5, if it is greater than 38 and the difference is less than 3. However, when I am going to submit the code to me d[and the error: EOF when Reading a…
-
-1
votes3
answers144
viewsCalculate the value of a multiplication using only summation and subtraction operators
I tried to write a program in which I must calculate the result of a multiplication through sum and subtraction operators only. I can’t write anything that works, follow the code as close as I got:…
-
-1
votes1
answer321
viewsA more efficient Bruteforce
I have a code I made in a few minutes that was supposed to be a "Bruteforce". works, but after 3 characters, it takes too long. I had some ideas to make it more efficient, such as saving in a…
-
-1
votes1
answer94
viewsHow to pass values up in a tree in javascript
Hello, I’m doing an exercise that consists in making an algorithm that plays the game of old, so far I managed to generate all the game paths and detect which lead to victory or defeat and organizes…
-
-1
votes2
answers282
viewsArray return
I have to do a function with the name saldoDeMesesComLucro where a array of a period of months, in the function I need to find out which of those months gave a valor > 0 and make the sum of this…
-
-1
votes1
answer62
views -
-1
votes1
answer554
viewsError 5% URI C - 1047 - Minutes Play Time
I can’t seem to solve this problem of URI. In the tests I performed, my solution worked perfectly, but when I submit the URI evaluation, I get the message that there is 5% error in the program.…
-
-1
votes1
answer49
viewsProblem with Conditional Structure If and Otherwise
I would like to know why the program does not display the Student Performance : Escreva("Digite a primeira nota: ") Leia(nota1) Escreva("Digite a segunda nota: ") Leia(nota2) media <- (nota1 +…
-
-1
votes1
answer90
viewsConvert int to str for loop
I would like the variable of input() retain its type int were only converted to string when exclusively entered with’s' digit so that I can exit the loop, without changing the while, there is some…
-
-1
votes2
answers57
viewsTrack data count shows wrong result
A city hall conducted a survey among its inhabitants, collecting data on the population’s salary. The city wants to know: a) Number of people with a salary higher than R $ 2000,00.Number of people…
-
-1
votes3
answers58
viewsThe result comes out another
I have tried to solve this exercise that I picked up on the internet. But it never comes out the value I want. What’s the reason? / João Papo-de-Pescador, a good man, bought a microcomputer to…
-
-1
votes1
answer285
viewsVisualg algorithm error - Simple average calculation and rating - Beginner
I’m a beginner and I’m learning algorithms. I started to make an algorithm for calculating simple average and also a classification based on average, but visualg accuses a series of errors in the…
-
-1
votes2
answers82
viewsWhat is the real complexity behind Sleep Sort compared to the others?
I know this is my first question here on stackoverflow in English. However I missed the mention of this algorithm called Sleep-Sort. From what I know its origin is "supposedly" unknown because the…
-
-1
votes1
answer135
viewsHow to write this algorithm in C
The equation A 5+B 5+C 5+D 5+E 5=F 5 such that 0<a<=b<=c<=d<=e<f<=75 has exactly one whole solution. write a program to find it. #include <stdlib.h> #include…
-
-1
votes1
answer45
viewsdata not ordered after execution C
I need to put the columns a in order, however, only the names are getting sorted correctly. The functions that sort the notes and sex are not working. Can anyone tell me where I’m going wrong? The…
-
-1
votes1
answer51
viewsHow to prove the complexity of an algorithm?
I have some questions about analyzing algorithm complexity, I have their correct answer (true or false), but I don’t know how to prove it, if someone can explain me the reasoning to get their real…
-
-1
votes1
answer32
viewsDiagonal Difference Hacker Rank Kotlin My solution approves in some but fails in the rest
fun diagonalDifference(arr: Array<Array<Int>>): Int { var tamanho = arr.size - 1 var i = 0 var diagonal1 = 0 var diagonal2 = 0 for(i in 0 .. tamanho){ diagonal1 += arr[i][i] diagonal2 +=…
-
-1
votes1
answer239
viewsHow do I send an error message? Discord.py
Hello, I was making a message with the discord.Embed, only that I want that in case the user does not send the message correctly, the bot send a message Embed error. I tried this way only that the…
-
-1
votes0
answers42
viewsJAVA I created a vector union algorithm, but it is returning the values of its union = 0
package EstruturaDeDados; import java.util.Arrays; import java.util.Scanner; public class testes { public static void main(String[] args) { Scanner ler = new Scanner(System.in); String repetir =…
-
-2
votes1
answer677
viewsAlgorithm to generate a character diamond
I’m trying to make a C program to generate a diamond as exemplified in the image below: I couldn’t get an algorithm to generate the characters and spaces needed on each line. What a reasonable way…
-
-2
votes2
answers72
viewsAlgorithm that checks whether the sum of any two items of an ordered array is equal to a number yielding wrong results
This pairSum algorithm should find if the sum of any two items in an array arr is equal to a given number target: function pairSum(arr, target){ for (var i=0; i<arr.length;){ for (var j =…
-
-2
votes3
answers797
viewsCount numbers 1 in binary number after decimal base conversion
In this program I need to count the number 1 present in the binary number after decimal base conversion. Follow the code: #include<stdio.h> #include<stdlib.h> #include<string.h>…
-
-2
votes3
answers254
viewsLogic to compare four values and find the smallest
It is correct to compare 4 values in this way? Se (A < B && A < C && A < D){ Escreva A; }; Senao Se (B < A && B < C && B < D){ Escreva B; }; Senao…
-
-2
votes2
answers146
viewsTransform String into Algorithm
Can anyone tell me if there’s a way I can turn a string into an algorithm ? for example: a = "1 + 1" => b = 1 + 1. For simple examples it’s easy to create a string interpreter, the problem is…
-
-2
votes1
answer149
viewsI wrote this code in Dev C++, it compiled but does not perform the operation
When I run and type a number it does not multiply, it only displays the message " Price:" and not the multiplication result. #include<stdio.h> main() { int quantidade; double valor;…
-
-2
votes1
answer30
views -
-2
votes2
answers1867
viewsCreate an algorithm, in JS, to list all primes smaller than or equal to N
I need to create an algorithm in Javascript, to list all prime numbers less than or equal to a given number. function primeNumber (num){ var num = 0; for (var i = 0; i <= num; i++){ if ((num % 1…
-
-2
votes1
answer736
viewsRender and display the Matrix in C (dev c++)
I have to do this: Make a program that loads a 12x4 matrix with the values of sales of a store, where each row represents one month of the year and each column represents a week of the month.…
-
-2
votes1
answer60
viewsHow do I read to read these numbers and sum all without having to add variable by variable type sum it 60 times
Algoritmo "questionario" Var Resposta: Caractere Var soma,Nota: Inteiro Inicio Escreval("Questionario ENEM 2018 ") Escreval("1) Qual a capital do…
-
-2
votes1
answer94
viewsA program that sums up n numbers where the odd numbers will be disregarded, where it works as it should
#include <stdio.h> int main() { int i, nmrs, n, soma = 0; printf("De quantos numeros quer fazer a soma? (impares serao desconsiderados)\n"); scanf("%d", &nmrs); for (i = 1; i <= nmrs;…
-
-2
votes1
answer31
viewsStop Loop For when a certain number is typed
I’m trying to stop a loop for when the number 42 is typed. Even my code is like this: var numero = prompt('Digite o numero') var arrNumero = [] arrNumero.push(numero) console.log(arrNumero) for (let…
-
-2
votes1
answer46
viewsDoubt about python/basic algorithms
I am making a personal challenge,develop the smallest program possible to manage a fibonati sequence and that shows the fi(gold number). Most recent code : nf = int(input("Quantos numeros da…
-
-2
votes0
answers12
viewsCryptography in C language
I need to make a pseudo-code to then pass in C-language from a Hill cipher encryption. The phrase to be encrypted will be inserted by the user and the key matrix as well. I cannot use character…
-
-2
votes1
answer85
viewsMy program seems not to be correct, what to improve?
maior50 = menor20 = maior10 = 0 x = 1 while x <= 20: idad = int(input("Digite sua idade:")) alt = float(input("Digite sua altura:")) peso = float(input("Digite seu peso:")) x = x + 1 if idad…
-
-2
votes1
answer28
viewsreceiving user values other than repeated numbers
Good morning! I’m a beginner in algorithm and I’m making an algorithm that receives from the user an array of 20 integer positions with values between 1 and 20, but there can be no repeated number…
-
-2
votes2
answers114
viewsMost efficient algorithm to find indices of the 2 elements of a list whose sum is equal to a certain value
The Challenge is simple, find two numbers from a given list that if summed result in a specific number and return the index of those numbers. That I solved, the problem is that in addition the…
-
-2
votes1
answer68
viewsRecursive function to mount file tree
I’m having trouble assembling a virtual directory tree with its respective files. The modeling is as follows: Table: folders id name company_id parent_folder (self relationship) I mounted the…
-
-3
votes1
answer315
viewsAlgorithm for temperature control
I am a computer engineering student and am working on a PCR Thermocycler. I need to have a certain precise temperature to be able to perform all the steps of the process, and I’m having some…
algorithmasked 10 years, 5 months ago Matheus Abner 21 -
-3
votes1
answer156
viewsMajor algorithms of sorting?
What are the main sorting algorithms? If possible with examples in C. I don’t know when to use one or the other.
-
-3
votes2
answers261
viewsHelp in Java: Arrays
Exercise: Make two lists of names in the form of arrays, compare how many names on List 1 are on List 2, and then calculate the percentage of these, about the percentage of total people on List 2.…
-
-3
votes4
answers623
viewsPrint ranges of numbers with final 5
I’m trying to print the numbers from 0 to 200 that have only the number 5 as the last digit. package Exercícios; public class NumerosQueComeçamComAlgarimo5 { public static void main (String [] args)…
-
-3
votes1
answer55
viewsHelp with C code
In the code below the intention was to create a vector with 10 spaces, then receive 10 values typed by the user, check if the values are equal or less than 0 and assign the value 1 in these cases,…
-
-3
votes3
answers386
viewsThe user will have 3 attempts to set the password
The following form does not open when the password is correct and if it is wrong continues to pass even if the password has typed 3 times. private void btnEntrar_Click(object sender, EventArgs e) {…
-
-3
votes1
answer204
viewsDetect digit repetition in Java
I need to make a program that reads a positive integer N. After reading this number, the program must evaluate if there are repeated digits in the number. For example: in 234571 there are no…
-
-3
votes2
answers144
viewsRepeat structure that compares equal values and prints the match
I have two arrays: operator.table_perm has screen ids and the array canvases has in addition to the id, the name of the screens. I need to create a repeat structure that compares the two arrays and…