I've written some code to calculate LCM for 3 numbers. My question is: why with line: std::cout << ""; code does work, and without this line code doesn't work? How it is possible that printing some text on screen, can affect on how program works? It is a matter of some buffering or smth. like this?
#include <iostream>
int NWD(int a, int b){
int r;
while (r != 0){
if (a>b)
r = a-b;
else
r = b-a;
a = b;
b = r;
}
return a;
}
int NWW(int a, int b){
std::cout << ""; // without this code doesn't work
return a*b/ (NWD(a,b));
}
int NWW3(int a, int b, int c){
return NWW(c, NWW(a,b));
}
int main()
{
cout << NWW3(1,7,9);
}