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
-
0
votes1
answer84
viewsReturn range of numbers according to the division of total numbers by an integer
Given the following situation: I need to create a function that receives as parameter (int value and int divisor). The idea is popular an array with the TOTAL of the range passed to the function.…
-
0
votes1
answer86
viewsMathematical and logical operators in Visualg
Why the codes highlighted in asterisk do not work the way I chose? I realized that using the smaller number first and the bigger number second, it works normally, but I’ve been itching to know why…
-
0
votes0
answers38
viewsCompare map<string,any> c++ 17
I can’t compare two maps . Ex: map<string, any> columnsMap = { {"status", 1}, {"client_delivered", 0}, {"client_notification", 0}}; map<string, any> columnsMap2 = { {"status", 1},…
-
0
votes2
answers42
viewsMiscalculation with While
In this exercise it is to type two numbers and print on the screen themselves, and the integers between them. However, if I type for example 10 and 20, the last number that appears is 19 instead of…
-
0
votes1
answer21
viewsDisplay array indices whose elements are greater than the average of them
I have an array, and I want it to display the numerical positions of the elements that are larger than the average of them: //2 - Solicite 5 números. Exiba os que estão acima da média. var num,…
-
0
votes6
answers444
viewsCounting multiples of an integer is giving very different values than expected
When receiving two integer numbers, I have to show how many multiples the number n1 (typed 3) has until you reach the n2 (typed 44). The right result should be: The number 3 has 14 multiples smaller…
-
0
votes1
answer1170
viewsVisualg algorithm over prime numbers in a repeat structure
I’m new to programming and I need help in a college exercise, I need an algorithm in Visualg that shows the prime numbers between an n1 number and an N2 number, using a repetition structure, where…
-
0
votes1
answer59
viewsHow do we know which object another object belongs to?
I’ve tried to come up with a simpler example, so I have a person who has a list of cars. If I have a C1 car, how will I know who it belongs to? public class Pessoa { private String nome; private…
-
0
votes1
answer47
viewsHow to apply the same condition/operation for each element of a vector in C
Hi, guys! I need to perform the same operation for all elements of a given vector. How to do this? More specifically, I need to check if an element any "x" has, in its two adjacent positions larger…
-
0
votes1
answer46
viewsMethod that returns the smallest between two parameters does not work
Create a method with two parameters that returns the smaller of two numbers passed as parameters When I don’t know how to solve, usually I will see the resolution with explanation, but it turns out…
-
0
votes3
answers325
viewsOccurrence of a digit on an integer using Python
Given an integer n, n > 0, and a digit d, 0 <= d <= 9, determine how many times d occurs in n. def main(): ocorrencia = 0 numeroReal = int(input("Digite um número inteiro positivo:\n"))…
-
0
votes2
answers126
viewsFactorial calculation in an arithmetic progression
I need to create a program that calculates the factorial started with 2 and add 2 more to each repetition until it reaches 20 times. Ex: 2!, 4!, 6!, 8!... I tried several ways, but every time I…
-
0
votes2
answers106
viewsHow to order questions randomly?
I’m finishing a project of Quiz Unity game in C#, let me try to explain what I need, I already ask the random questions, but I want the answers to be displayed at random as well. I have a list of 5…
-
0
votes1
answer179
viewsC code skipping user input
Hello! I am Newbie and I am trying to make a program to read a list of information inserted in it. Until the first line it works, but from the second register he no longer reads the name, putting…
-
0
votes1
answer61
viewsVariable returning value that was declared initially and not what the user reported
cont = soma = maiorv = media = 0 r = 'S' menorv = 0 while r in 'Ss': n = int(input('Informe um número inteiro: ')) cont += 1 soma += n if n == 1: maiorv = menorv = n else: if n > maiorv: maiorv =…
-
0
votes2
answers73
viewsHow to use multiple unique "if" in PHP?
I want to make a condition for when a value is selected, the condition is like this at the moment: if (!empty($_GET['faixa_de_preco'])) { $valor = $_GET['faixa_de_preco']; if ($valor == 1) { $result…
-
0
votes0
answers42
viewsHTML pages with read/write variables
I need support on this embedded project, using ESP32 and Arduino IDE. The difficulty would be to display and read VARIABLES on the HTML page because I only found these examples: Reference in…
-
0
votes0
answers33
viewsHow to find subsequences of a given vector, excluding given positions?
Given the vector v: [7 , 8 , 30 , -2 , 9] And the vector rem, which contains, in ascending order, the positions removed: [1 , 4] It is necessary to do a function seq(rem,n) (where n is the number of…
-
0
votes1
answer40
viewsYou need to indicate how many times the highest number has been read, but you’re not counting that
I’m not finding out how many times a certain higher number has been read. #include <stdio.h> int main (){ int i, num, maior = 0; printf ("Ao finalizar, digite '00', sem aspas, para obter o…
-
0
votes1
answer64
viewsfind a word in a random character list
I need help in this python exercise Marlon likes to cut letters from his magazines, then reorganize them to form sentences. Once, he cut out the letters ZEPUAMAOIZ and realized that changing the…
-
0
votes2
answers152
viewsOrdering values by pointers
Good, I was doing an exercise that asked to read 3 real numbers, order them and show in an orderly way. I thought making a function that uses pointers would be a good idea, but the program always…
-
0
votes1
answer49
viewsHow does this algorithm look for the smallest value of an array?
I’m starting studies and I’m studying the book I understand the algorithms and in cap 2 I don’t understand this algorithm. Here in case is to find the lowest value of an element. def…
-
0
votes2
answers174
viewsFind out which number from 1 to N is missing from a list with N - 1 numbers
Write a function that, given a list of N 1 integers numbered from 1 to N, finds out which integer of that range is missing. Input: The input parameter is an L list of size N 1 containing integers…
-
0
votes1
answer47
viewsAlgorithm in C loop of for repeating response
Guys I’m going to college and I got stuck in a list exercise, it’s a C algorithm, could help me My problem is that I put a number to serve the variable x and it calculates about 4 times properly,…
-
0
votes0
answers134
viewsExercise in python 3n +1
3n +1 Description Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2. If n is odd, multiply by 3 and add 1. Repeat this process…
-
0
votes1
answer70
viewsAlgorithm performance in JAVA
Good afternoon, you guys. I have the following exercise to deliver: Challenge Mr Milli, Petland City resident, is the famous owner of the world’s largest board game factory. Recently, he had the…
-
0
votes1
answer37
viewsJS - Div does not move around the screen
This code is a copy of a video that teaches js to beginners. It is practically an exact copy of what I see on the screen, but with me it does not run at all. The only thing the 'ball' does is go up…
-
0
votes1
answer104
viewsWhy does my running function only return "0"?
I’m doing a function that gets a string (char str[10]) and she has to return 1 if to string contain the word "wing" and otherwise return 0. To make it easier to understand what I tried to do, I’ll…
-
0
votes0
answers55
viewsProgram enters Infinite Loop - Problem "Horse Ride" in C
The problem of the horse consists of which, the horse is placed on the board emptiness and, following the rules of the game, need to go through all the houses exactly once in consecutive moves. ie…
-
0
votes1
answer71
viewsHow to implement the sine function using Taylor series in Python?
I’m having a little trouble with my code. I need to create a code that calculates the sine of an angle using the Taylor series, in the range of [-pi, +pi]. Thus, the sine function repeats. That is,…
-
0
votes1
answer29
viewsJava - Uninitialized "x" variable
I’m having a question: The code is as follows:: package yan.exercises.java.struct.repeat; import java.util.Scanner; public class exe2 { public static void main(String[] args) { Scanner scan = new…
-
0
votes0
answers28
viewsQueen`s Attack II Hackerrank - C# - Terminated due to timeout
Good afternoon. I made the challenge of Queen’s Attack (I started programming a few days ago) and I can’t get 100% approval on this challenge. It’s said that my code needs to be optimized, but I…
-
-1
votes2
answers177
viewsHow to create an algorithm that automatically tracks certain pages of a website?
I have a platform where people can post comments write reviews and I at this point need to create an algorithm in which track me those same areas of the site if someone write a comments less…
algorithmasked 9 years, 8 months ago César Sousa 2,025 -
-1
votes3
answers1472
viewsProblem using if Elif Else (Else error)
n = input ("informe seu nome ") b1 = float(input("informe sua nota em Biologia no 1º Bimestre ")) b2 = float(input("informe sua nota em Biologia no 2º Bimestre ")) b3 =…
-
-1
votes1
answer93
viewsWhy does the following code not work?
The code should receive a number of student grades, print the grade average and how many grades are 10% below and 10% above average. The code is like this: quantidade = int(raw_input()) inicio = 0…
-
-1
votes1
answer333
viewsDelphi => C#: generic function to return billet DV
I’m having problems with a custom Module 11 function (which correctly returns the billet dv of any bank) that already had it in Delphi, and how I’m needing it to implement in a C system#. So I tried…
-
-1
votes1
answer261
viewsSeparate listings of an object for each object of the type of another class
Good night. My question is in relation to the algorithm of my project, I am trying to make an application where each Customer can place several orders but each order belongs to a different Customer.…
-
-1
votes2
answers238
viewsWhy is this algorithm in Java not running?
import java.util.Scanner; public class CalculoSalarioLiquido { public static void main (String args []) { System.out.println("Programa para calcular o Salário Líquido: ");…
-
-1
votes1
answer118
viewsPrint a square where prime number positions receive a "#" and the others receive a "_"
#include <stdio.h> int main () { int n, i, j; printf("Digite o tamanho do quadrado\n"); scanf("%d", &n); for(i=1; i<=n; i++) { for(j=1; j<=n; j++) { if(i%j == 0) { printf("#"); }…
-
-1
votes1
answer478
viewsExercise: Turn decimal to binary and find 1’s
#include<stdio.h> int main() { int k,repeticao; int valor, numero; int paridade = 0; scanf("%d", &repeticao); for( k = 0; k < repeticao; k++ ){ int numero,sequencia; scanf("%lld",…
-
-1
votes1
answer55
viewsProgram with 3 files
I made a code in c++ that works if it’s all inside the main.cpp. When I create other files, like a header it from the indefinite reference error. I have done everything and only managed to make it…
-
-1
votes1
answer1612
viewsThe first 100 prime numbers
I created a code to print on the screen the first 100 primes, but the screen is blank. I know that I am probably not doing the best way, I would like the correction of this and the best way to solve…
-
-1
votes1
answer63
viewsDivision and conquest algorithms design
I need to design this algorithm using the paradigm of division and conquest (strong induction). I’m not getting out of place... Let A and B be two vectors of integers such that the total number of…
-
-1
votes1
answer61
viewsPrime numbers are not listed
I’m trying to create a C program that shows all prime numbers from 1 to 100 using brute force, but my program shows nothing on the screen. #include <stdio.h> #include <stdlib.h> int…
-
-1
votes1
answer40
viewsList a date period by the day of the week?
I need to do a function in Javascript/jQuery that I take the value of two fields of date format and it returns me a sequence of dates as I choose: 1st or 2nd Tuesday of the selected period in the…
-
-1
votes1
answer30
viewsWhat is the best way to return function-specific error codes?
I have heard that it is good practice to return only true or false (1 or 0) functions, but if I create a function that checks a string, and I want to know what errors occurred in it, I usually…
-
-1
votes1
answer285
viewsArduino with counter
I can’t understand what’s wrong with that code S1 once and M1 stay turned on but it turns off after a while. The program also doesn’t count as it should. The question is this: In the system below…
-
-1
votes1
answer187
viewsHow to discover all possible paths to visit all vertices of a graph?
I need to store all possible routes to visit the vertices of a graph without going through the same vertex twice (TSP), I thought of generating the routes randomly and storing all that are not…
-
-1
votes1
answer65
viewsHow to determine if it is possible to scale processes using the EDF (Earliest Deadline First) algorithm?
Well, my teacher asked me to do an algorithm IN C-LANGUAGE that receives a value N which is the number of processes to be evaluated. Then it receives N pairs of values, each pair in a row. Each row…
algorithmasked 6 years, 3 months ago Victor OCV 393 -
-1
votes1
answer1169
viewsHow to interrupt in Visualg?
Good evening, everyone. How do I interrupt a command in visualG? What has been requested: Write an algorithm that writes a sentence on the screen until the letter "F" is typed (without quotation…