Advertisement
DasShelmer

4.19

Oct 13th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. void calc(long &b, int &i) {
  6.     b = (i % 2 == 0 ? b + 3 : b * 2);
  7. }
  8.  
  9. int main() {
  10.     setlocale(LC_ALL, "Russian");
  11.     int n, i;
  12.     long b = 0;
  13.     cout << "Введите значение n (n > 0): ";
  14.     cin >> n;
  15.     n --;
  16.     cout << "  n    b(n)" << endl;
  17.     cout << setw(3) << 1 << setw(6) << b << endl;
  18.     for (i = 0; i < n; i++) {
  19.         calc(b, i);
  20.         cout << setw(3) << i + 2 << setw(6) << b << endl;
  21.     }
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement