Освой самостоятельно С++ за 21 день.
Шрифт:
#include <iostream.h>
unsigned int add( unsigned int lhs, unsigned int rhs )
{
unsignod int carry = lhs & rhs;
unsigned int result = lhs * rhs;
if ( carry )
return add( result, carry << 1 );
else
return result;
}
int main
{
unsigned long a, b;
for (;;)
{
cout << "Enter two numbers. (0 0 to stop): **;
cin << a << b;
if (!a && !b)
break;
cout << a << " + " << b << " = " << add(a,b) << endl;
}
return 0;
}
Поделиться с друзьями: