malixds_

inf4.7

Dec 10th, 2021 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     setlocale(LC_ALL, "ru");
  6.     int m, i1, ilast, c, a, S, res;
  7.     cout << "Введите m: " << endl;
  8.     cin >> m;
  9.     cout << "Введите i1: " << endl;
  10.     cin >> i1;
  11.     cout << "Введите ilast: " << endl;
  12.     cin >> ilast;
  13.     if (ilast > i1) {
  14.  
  15.     }
  16.     else {
  17.         while (ilast < i1) {
  18.             cout << "Вы ввели некорректные значения. Требуется ilast > i1. Повторите попытку: " << endl;
  19.             cout << "Введите значение i1: "; cin >> i1;
  20.             cout << "\nВведите значение ilast: "; cin >> ilast;
  21.         }
  22.     }
  23.     cout << "Введите c: " << endl;
  24.     cin >> c;
  25.     cout << "Введите a: " << endl;
  26.     cin >> a;
  27.     cout << "Введите S: " << endl;
  28.     cin >> S;
  29.     res = ilast - i1;
  30.     int* arr = new int[ilast];
  31.     cout << "S" << "(" << i1 << ") = "  << S;
  32.     arr[i1] = S;
  33.     cout << endl;
  34.     for ( ; i1 < ilast; i1++) {
  35.         arr[i1 + 1] = (m * arr[i1] + a) % c;
  36.         cout << "S" << "(" << i1 + 1 << ") = " << arr[i1 + 1] << endl;
  37.     }
  38. }
Add Comment
Please, Sign In to add comment