Questions tagged as 'algoritmo'

1
answer

Code works sometimes yes and sometimes not

This is my code: #include <iostream> #include <cstdlib> #include <ctime> using namespace std; void exchange (int *arr, int i, int j) { if (i == j) return; int aux = arr[j]; arr[j] = arr[i]; arr[i] = a...
asked by 24.12.2016 / 20:56
1
answer

Algorithm that reads 50 numbers, calculate and show arithmetic mean, largest and smallest number [closed]

I'm a beginner in programming and I came across an algorithm that I need to solve but I'm not getting it. Read the 50 numbers using the "for i from 1 to 50 knife" I did, now I can not enter the arithmetic mean in this and much less display th...
asked by 05.10.2014 / 22:21
1
answer

Interpreting an algorithm

I have to solve a problem with the following statement:    The houses on that street       Context       A computer programmer lives on a street with houses on only one side . The houses on this street are numbered sequentially starting f...
asked by 29.05.2014 / 17:51
3
answers

Error in MergeSort sorting algorithm in Java

I was doing the MergeSort sorting algorithm in Java for study purposes and every time it runs it gives error. I have already reviewed the logic of the algorithm, I already replace the array of integers with a ArrayList , I already tried to...
asked by 20.03.2018 / 20:55
1
answer

Exercise Algorithm Given the values of real x and positive natural n, calculate

Given the values of x real and n natural, calculate: S = (x+1)/1! + (x+2)/2! + (x+3)/3! + ... + (x+n)/n! So far what I did was this: leia x leia n nFatorial = 1 contadorFatorial = 0 enquanto contadorFatorial < n faça...
asked by 12.09.2018 / 19:37
1
answer

How to tell if a number is integer

I need to develop an algorithm where it divides a number by 2 until it reaches the rest of the division, and I need to know if the rest of this division is an integer, what method can I apply to develop this problem? where: funcao menu_8():i...
asked by 01.06.2016 / 20:17
1
answer

Simple permutation algorithm

I'm trying to create a simple permutation algorithm where you pass any number eg 123 and it should return the largest number without repeating. I tried something of this type more when I step 4242 it does not return me 4422 but 4242 as larger....
asked by 31.01.2016 / 00:22
1
answer

Sort algorithm does not work

There is something missing in the program. It checks the order with a single number or a single time. #include <stdio.h> #include <stdlib.h> /*4)escrever 10 números e ordenar em forma crescente e decrescente*/ int main() {...
asked by 15.04.2015 / 00:27
3
answers

Function that calculates the factorial of a number [closed]

int fatorial(int n, int f){ int resultado; while(n>1){ f=1; resultado=(n*f); f=f-1; } return (resultado); } int main(void){ int resultado; int n; int f; printf("Digite o numero a ser fatorado:\n"); scanf("%d", &n); resultado=fatorial(n,f)...
asked by 02.10.2018 / 23:46
1
answer

Perfect numbers

algoritmo "numeros_perfeitos" var c, n:inteiro nv, np, npv:real inicio para n <- 1 ate 100 faca para c <- 1 ate n faca se n % c = 0 entao nv <- n / c se nv < n entao np <- nv + np fimse...
asked by 03.10.2017 / 15:19