Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <fstream>
- #include <string>
- #include <ctime>
- #include <vector>
- using namespace std;
- class BaseClass
- {
- private:
- short const array_lenght = 10;
- short array_num[array_lenght];
- bool array_flag[array_lenght];
- public:
- void create_array()
- {
- srand(unsigned int (time(NULL)));
- for (short i=0; i<array_lenght; ++i) {
- array_num[i] = rand()+rand()- 32768;
- }
- }
- void print_array()
- {
- for (short i=0; i<array_lenght; ++i) {
- std::cout << array_num[i] << std::endl;
- for (short j=15; j>-1; --j) {
- std::cout << ( (array_num[i] >> j) & 1);
- }
- std::cout << std::endl;
- }
- std::cout << std::endl;
- }
- void searching()
- {
- int count = 0;
- for (short i=0; i<array_lenght; ++i) {
- if ((array_num[i]&14) == 14) {
- count = count + 1;
- bool array_flag[i]=true;
- }
- else{
- bool array_flag[i]=false;
- }
- }
- cout<<"counter = "<<count;
- }
- };
- class SubClass:public BaseClass
- {
- protected:
- public:
- };
- int main()
- {
- BaseClass x;
- x.create_array();
- x.print_array();
- x.searching();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement