Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <math.h>
- using namespace std;
- ////////////////////////
- void RusText(void);
- class AnyClass
- {
- public:
- //переменные
- int n;
- int *arr;
- int *arrNew;
- int cnt;
- int indx;
- /////////////
- void Inputer()
- {
- int a;
- arr= new int [cnt];
- if (arr==NULL)
- {
- delete [] arr;
- cout << "Ошибка Выделения Основной Памяти" << endl;
- return;
- }
- do
- {
- cout << "Вводите корректные целые числа..." << endl; cin >> n;
- if (!(n%3))
- {
- cout << "Индекс= " << indx << endl;
- if (indx==cnt)
- {
- cnt=cnt +3;
- arrNew= new int [cnt];
- if (arrNew==NULL)
- {
- cout << "Ошибка Выделения Дополнительной Памяти" << endl;
- delete [] arr; delete [] arrNew;
- return;
- }
- for (a=0; a< indx; a++) arrNew[a]= arr[a];
- delete [] arr;
- arr= arrNew;
- }
- arr[indx]= n; indx++;
- }
- else cout << "Число 'НЕКРАТНОЕ 3' в массив не попало" << endl;
- } while (cin.good());
- cout << "Останов: некорректное целое число. Смотрим результат" << endl;
- int ln=3; indx--;
- for (a=0; a< indx; a++)
- {
- if (!ln) { cout << endl; ln= 3; }
- ln--;
- cout << arr[a] << "\t";
- }
- }
- //////////////Конструктор
- AnyClass ()
- {
- cnt= 3; indx=0;
- }
- //////////////Деструктор
- ~AnyClass()
- {
- delete [] arrNew;
- }
- };
- int main(int argc, char **argv)
- {
- RusText();
- AnyClass a;
- a.Inputer();
- cout << endl; system("pause");
- return 0;
- }
- ////////// Руссификация сообщений //////////////////////////////////
- void RusText(void)
- {
- system("chcp 1251 > nul");
- SetConsoleTitle(TEXT("ОтветыМейлРу")); //Для совместимости с VS
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement