Questions tagged as 'algoritmo'

1
answer

Algorithm in Java, increase age;

I wanted to know how to do an algorithm where I entered a year, and the value increased with age, like year 2016 = 1, year 2017 = 2, in a method. Something like this: int fazAniversidade(int ano) { if(ano == 2015) { this.idade +...
asked by 09.07.2015 / 23:45
2
answers

Average data entered algorithm

package ifal2; import java.util.Scanner; public class Lista3Questao4 { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int idade=0, contM=0, contF=0; double soma=0, somaaltura=0,...
asked by 01.08.2018 / 04:28
1
answer

Why is not entering if?

Example: user type 4A6 then in this string the 2nd position is capital. How do I say that the position the user typed is capital? Follow the code to clarify public class JogoMatematica { public static void main(String[]...
asked by 28.03.2017 / 19:26
2
answers

Algorithm implementation in VisuAlg [closed]

Make a program that receives two numbers and performs one of the operations listed below according to the user's choice. If an invalid option is entered it will show error message and finish running the program. The options are: 1. Average betwe...
asked by 10.09.2017 / 03:58
2
answers

How to optimize the calculation of plots in "broken"

I have an application that, depending on the format of the portion that the user selects, the system will return the amount of that parcel. For example: Assuming a request for $ 50,000 twice, the system will store two records containing $ 25,000...
asked by 24.10.2017 / 23:39
1
answer

Difference between algorithms that read numbers until you receive the number 999

What's the difference between these codes? First code: cont = 0 n = 0 total = 0 n = int(input("Digite 999 para parar")) while n != 999: n = int(input("Digite 999 para parar")) cont += 1 total += n print(total) Second code:...
asked by 14.12.2018 / 20:00
2
answers

Display the first 5 numbers by 3, discarding the number 0

I can not display the first 5 divisibles by 3, I put a counter variable, but it returns another number. #include <stdio.h> #include <stdlib.h> int main() { int n = 20; for(int i=1; i<=n; i++) { if(i%3 == 0)...
asked by 02.03.2016 / 02:03
1
answer

Bubble Sort in Python3

def bubble_sort(list): for i in range(len(list)): for j in range(len(list)-1): if list[j] > list[j+1]: list[j], list[j+1] = list[j+1], list[j] else: continue I just did this bubble sort, but I...
asked by 04.07.2018 / 14:55
1
answer

How to check if all elements of a vector are between 4 and 4?

I want to compare if all elements of a vector are between -4 and 4, if it is, the algorithm will execute the method. for(int i=0; i< j; i++){ if(vet[i] > -4 && vet[i] <4) calcular(4); }     
asked by 23.11.2017 / 01:46
1
answer

Fibonacci question in Java

I have an issue and its resolution, which needs to be with while or do-while . But I did not understand the resolution, could anyone explain? I will comment on the specific doubt of each line.    The Fibonacci Sequence is a seque...
asked by 09.11.2017 / 20:18