Ir ao conteúdo
  • Cadastre-se

Thiagos13 Matos

Membro Júnior
  • Posts

    2
  • Cadastrado em

  • Última visita

Reputação

0
  1. kklkkk assim, valeu, mas eu sou mt iniciante e n entendi mt bem n jshusu mas valeu
  2. #include <iostream> #include <math.h> using namespace std; int main () { int x, y, z; cout << "This program finds the number of multiples of any number among other two.\n"; cout << "Enter the number to which you want to find the multiples\n"; cin >> z; cout << "Enter the first number:\n"; cin >> x; cout << "Now, enter the second number:\n"; cin >> y; if (y>z and x>z and z*z>x and z*z>y) { cout << "Has " << fabs((x - y) / z) - 1 << " multiples of " << z << " between " << x << " and " << y << endl; } if (x<z) { cout << "Has " << fabs((x - y) / z) + 1 << " multiples of " << z << " between " << x << " and " << y << endl; } if (y<z) { cout << "Has " << fabs((x - y) / z) + 1 << " multiples of " << z << " between " << x << " and " << y << endl; } if (x>z and z*z<x and z*z<y) { cout << "Has " << fabs((x - y) / z) << " multiples of " << z << " between " << x << " and " << y << endl; } if (y>z and z*z<x and z*z<y) { cout << "Has " << fabs((x - y) / z) << " multiples of " << z << " between " << x << " and " << y << endl; } /*if (x<y, x<z) { cout << z*(1*(y/z) + (y/z*(y/z - 1))/2); } if (x>y, y<z) { cout << z*(1*(x/z) + (x/z*(x/z - 1))/2); } if (y>z and x>z and y>x) { cout << z*( x/z * (y/z - x/z + 1) + ( y/z * (y/z - x/z)) / 2 ); } if (y>z and x>z and y<x) { cout << z*( y/z * (x/z - y/z + 1) + ( x/z * (x/z - y/z)) / 2 ); } */ return 0; } glr, esse é meu código pra falar os a quantidade de múltiplos de um número entre outros dois, e dps mostrar a soma deles. a parte em comentário é porque a expressão está errada, pois quando a divisão da decimal, eu tenho q considerar o inteiro e somar um, mas n sei fzr. enfim, se puderem me ajudar ou tiverem dicas para melhorar o código.. valeu

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...