Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<conio.h>
- #include <iomanip>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "");
- int* arr = nullptr;
- int l = 0, max = -1, n = 0, m = 0;
- string str;
- cout << "Введите количество элементов:" << endl;
- while (n <= 0) {
- cin.clear();
- cin.ignore(cin.rdbuf()->in_avail());
- cin >> n;
- }
- arr = new(nothrow) int(n);
- if (!arr) {
- cout << "Ошибка выделения памяти!";
- return 0;
- }
- for (int i = 0; i < n; ) {
- cin.clear();
- cin.ignore(cin.rdbuf()->in_avail());
- cout << "Введите элемент[" << i + 1 << "]" << endl;
- cin >> arr[i];
- if (cin.peek() != '\n') {
- cout << "Недопустимое значение!" << endl;
- continue;
- }
- i++;
- }
- system("cls");
- for (int i = 0; i < n; i++)
- cout << arr[i] << endl;
- int g = 0;
- int e = 0;
- for (int i = 0; i < n; i++) {
- m = arr[i];
- g = 0;
- while (m) {
- m /= 10;
- g++;
- }
- cout << endl << setw(5) << "i - " << i + 1 << ":";
- if (e < g) {
- for (int j = 0; j < n; j++) {
- if (i == j)
- continue;
- cout << endl << setw(5) << j + 1;
- if (arr[i] == arr[j]) {
- max = i;
- cout << "------" << l << endl;
- }
- }
- }
- }
- if (max == -1) {
- cout << "Нет повторяющихся последовательностей!";
- return 134;
- }
- cout << endl << setw(40) << "Нужная последовательность:" << setw(6) << max + 1 << setw(6) << arr[max];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement