Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int func(int x, int y, int s)
- {
- if (y % 2 == 1)
- {
- s += x;
- }
- if (y>1) {
- x *= 2;
- y /= 2;
- s = func(x, y, s);
- }
- return s;
- }
- int main()
- {
- int a = 0, b = 0, summe = 0;
- cout << "Aegyptische Multiplikation" << endl;
- cout << "geben sie zwei zahlen ein " << endl;
- cin >> a;
- cin >> b;
- cout << a << " * " << b << endl;
- summe = func(a, b, summe );
- cout << summe << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement