Bob103

бесконечная сумма

Nov 26th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include<iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. double b=1.0/3.0;
  7. double s=0;
  8. cout << "e=";
  9. double e;cin >> e;
  10. int n=1;
  11. while (fabs(b)>= e)
  12. {
  13. s += b;
  14. b=-b/9.0;
  15. n++;
  16. }
  17. cout << "s=" << s << endl;
  18. system("pause");
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment