-1

The program should first ask that I enter how many times it should ask me for two numbers. After I give two numbers it should find the LCM of them and do the operation as many times as I entered in the beginning.

It opens and waits for me to give the numbers and does nothing.

#include <iostream>

using namespace std;

int ile ;
int grupa1, grupa2 ;
int wynik ;
int dzielnik = 0;

int main()
{
    cin >> ile ;
    for (int i=0; i <= ile ; i++ )
    {
        cin >> grupa1 >> grupa2 ;
        do
        {
            do
            {
                dzielnik ++ ;
              } while ((dzielnik % grupa1 != 0 && dzielnik % grupa2 !=0 )     || dzielnik < grupa1 + grupa2) ;

                if (dzielnik % grupa1 == 0 && dzielnik % grupa2 == 0 )
            {
            grupa1 = grupa1 / dzielnik ;
            grupa2 = grupa2 / dzielnik ;
        }
        else if (dzielnik >= grupa1 + grupa2)
        {
            wynik = grupa1 * grupa2 ;
            cout << wynik ;
        }
    }
    while (wynik == grupa1 * grupa2) ;
    dzielnik = 0;
}
return 0;

}

kometen
  • 6,536
  • 6
  • 41
  • 51
gabi 13
  • 17
  • 2

1 Answers1

0

cout is buffered and won't display anything until it has 1) been provided with enough data or 2) been flushed.

Change this line:

cout << wynik ;

To this:

cout << wynik << endl;

And you should see some output.


Also, you should consider fixing your indentation. Currently it's very misleading. The main for lines up with a while and the internal do lines up with an else if.

Mr. Llama
  • 20,202
  • 2
  • 62
  • 115