#include <functional>
#include <iomanip>
#include <iostream>
#include <vector>
#include <typeinfo>

#include <cstdlib>

using namespace std;

unsigned int myAdd(unsigned int a, unsigned int b)
{
    unsigned int carry = a & b;
    unsigned int result = a ^ b;
    while(carry != 0)
    {
        unsigned int shiftedcarry = carry << 1;
        carry = result & shiftedcarry;
        result ^= shiftedcarry;
    }
    return result;
}

int main()
{
	cout << "30000 + 1337 = " << myAdd(30000,1337) << endl;
	
	srand(time(0));
	
	for(unsigned i(0); i < 200000; i++){
		unsigned temp = rand();
		if(i + temp != myAdd(i,temp)) cout << "nie zgadza sie dla wartosci " << i << " + " << temp << endl;
	}
}