Advertisement
JewishCat

rek_ryad_26v

May 23rd, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <cstdlib>
  3. #include <cmath>
  4. #include <math.h>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. void rek_r(double y0, double y1);
  10. int main() {
  11.     double y0 = 0.5;
  12.     double y1 = 0.25;
  13.     rek_r(y0, y1);
  14.     system("PAUSE");
  15.     return 0;
  16. }
  17. void rek_r(double y0, double y1) {
  18.  
  19.     double sum;
  20.     int i = 2;
  21.     do {
  22.         sum = (tanh(y0 * y1)) / i;
  23.         //cout  << i << " - " << sum << endl;
  24.         i++;
  25.         y0 = y1;
  26.         y1 = sum;
  27.         if (i > 50) {
  28.             cout << "Rayd rashod";
  29.             break;
  30.         }
  31.     } while (fabs(y0 - y1) > 0.0001);
  32.     if (i < 50) {
  33.         cout << "Rayd  shod. Summa:" << sum;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement