Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- double ryad(double a, double b);
- int main() {
- double a = 1;
- double b = 0.5;
- cout << "Summa ryada: ";
- cout << ryad(a, b);
- system("pause");
- return 0;
- }
- double ryad(double a, double b) {
- double sum = 0;
- double buf = -(a*b / 2);
- a = b;
- b = buf;
- int i = 2;
- do {
- sum += buf;
- buf = -(a*b / 2);
- a = b;
- b = buf;
- } while (fabs(a) > fabs(b));
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement