Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int func(int x, int y, int s)
  8. {
  9.  
  10.     if (y % 2 == 1)
  11.     {
  12.         s += x;
  13.     }
  14.     if (y>1) {
  15.         x *= 2;
  16.         y /= 2;
  17.  
  18.         s = func(x, y, s);
  19.     }
  20.  
  21.     return s;
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27.     int a = 0, b = 0, summe = 0;
  28.  
  29.     cout << "Aegyptische Multiplikation" << endl;
  30.     cout << "geben sie zwei zahlen ein " << endl;
  31.     cin >> a;
  32.     cin >> b;
  33.     cout << a << "     *     " << b << endl;
  34.     summe = func(a, b, summe );
  35.  
  36.     cout << summe << endl;
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement