Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. float berechnegewicht(const unsigned int cui_reiskorngewicht, const unsigned int cui_spielfelder)
  4. {
  5. unsigned int ui_gewicht = cui_reiskorngewicht;
  6. for (int i = 1; i < cui_spielfelder; i++)
  7. {
  8. ui_gewicht = (ui_gewicht << 1) + cui_reiskorngewicht;
  9. }
  10. return (float)ui_gewicht / 1000;
  11. }
  12.  
  13. void main()
  14. {
  15. unsigned int ui_spielfelder;
  16. unsigned int ui_reiskorngewicht = 25;
  17.  
  18. std::cout.precision(4);
  19. std::cout << "geben sie die anzahl der spielfelder ein: ";
  20. std::cin >> ui_spielfelder;
  21. std::cout << "ein reiskorn wiegt " << (float)ui_reiskorngewicht / 1000 << " kg.\n";
  22. std::cout << "alle reiskörner auf dem spielfeld wiegen kombiniert " << std::fixed << berechnegewicht(ui_reiskorngewicht, ui_spielfelder) << " kg\n";
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement