Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "ru");
- int m, i1, ilast, c, a, S, res;
- cout << "Введите m: " << endl;
- cin >> m;
- cout << "Введите i1: " << endl;
- cin >> i1;
- cout << "Введите ilast: " << endl;
- cin >> ilast;
- if (ilast > i1) {
- }
- else {
- while (ilast < i1) {
- cout << "Вы ввели некорректные значения. Требуется ilast > i1. Повторите попытку: " << endl;
- cout << "Введите значение i1: "; cin >> i1;
- cout << "\nВведите значение ilast: "; cin >> ilast;
- }
- }
- cout << "Введите c: " << endl;
- cin >> c;
- cout << "Введите a: " << endl;
- cin >> a;
- cout << "Введите S: " << endl;
- cin >> S;
- res = ilast - i1;
- int* arr = new int[ilast];
- cout << "S" << "(" << i1 << ") = " << S;
- arr[i1] = S;
- cout << endl;
- for ( ; i1 < ilast; i1++) {
- arr[i1 + 1] = (m * arr[i1] + a) % c;
- cout << "S" << "(" << i1 + 1 << ") = " << arr[i1 + 1] << endl;
- }
- }
Add Comment
Please, Sign In to add comment