Advertisement
Risonna

lab3_n4

Nov 19th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include "cmath"
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a, b, i, r;
  8.     //a(i) = 3b(i-a)+2(i-a)
  9.     //b(i) = 2a(i-1)+b(i-1)
  10.     a = 1; b = 1;
  11.     for (i = 2; i <= 16; i++)
  12.     {
  13.         if(a==1 && b==1)
  14.         {
  15.             cout << "a" << 1 << "=" << a << "\n";
  16.             cout << "b" << 1 << "=" << b << "\n";
  17.             r = a;
  18.             a = (3 * r) + (2 * b);
  19.             b = (2 * r) + b;
  20.             cout << "a" << i << "=" << a << "\n";
  21.             cout << "b" << i << "=" << b << "\n";
  22.         }
  23.         else
  24.         {
  25.             r = a;
  26.             a = (3 * r) + (2 * b);
  27.             b = (2 * r) + b;
  28.             cout << "a" << i << "=" << a << "\n";
  29.             cout << "b" << i << "=" << b << "\n";
  30.         }
  31.  
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement