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...
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...
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...
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...
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...
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...
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....
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()
{...
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)...
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...