Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <string>
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <algorithm>
- #include <stdlib.h> /* srand, rand */
- #include <time.h> /* time */
- using namespace std;
- class ArrayUser
- {
- public:
- vector <int> a0;
- vector <int> a1;
- int szArr;
- ArrayUser()
- {
- szArr= 0;
- while (szArr<1)
- {
- cout << "Размер массива = "; cin >> szArr;
- }
- }
- /////////////////
- void InitArr()
- {
- int i=0; int d;
- srand (time(NULL));
- while (i<szArr)
- {
- d= rand() % 77 - 31; // [-31;45]
- a0.push_back(d);
- i++;
- }
- }
- //////////////////
- void OutArrA0(bool f)
- {
- int i=0; int d;
- (f) ? d= a0.size() : d= a1.size();
- while (i<d)
- {
- (f) ? cout << a0[i] : cout << a1[i];
- cout << '\t';
- i++;
- }
- }
- ////////////////
- void FuncUser()
- {
- int i= 0; int d;
- while (i<a0.size())
- {
- d= a0[i];
- if (d%2) a1.push_back(d);
- i++;
- }
- }
- };
- int main(int argc, char **argv)
- {
- system("chcp 1251 > nul"); // Руссификация сообщений
- setlocale(LC_ALL, "Russian");
- ArrayUser au; au.InitArr();
- au.OutArrA0(true);
- au.FuncUser();
- cout << endl;
- au.OutArrA0(false);
- cout << endl;
- system("pause"); // system("pause > nul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement