chiva13

Untitled

Aug 29th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <fstream>
  4. #include <string>
  5. #include <ctime>
  6. #include <vector>
  7. using namespace std;
  8.  
  9.  
  10. class BaseClass
  11. {
  12. private:
  13.     short const array_lenght = 10;  
  14.     short array_num[array_lenght];
  15.     bool array_flag[array_lenght];
  16. public:
  17.  
  18. void create_array()
  19. {  
  20.     srand(unsigned int (time(NULL)));
  21.     for (short i=0; i<array_lenght; ++i) {
  22.         array_num[i] = rand()+rand()- 32768;
  23.     }
  24. }
  25.  
  26. void print_array()
  27. {
  28.     for (short i=0; i<array_lenght; ++i) {
  29.         std::cout << array_num[i] << std::endl;
  30.         for (short j=15; j>-1; --j) {
  31.             std::cout << ( (array_num[i] >> j) & 1);
  32.         }
  33.         std::cout << std::endl;
  34.     }  
  35.     std::cout << std::endl;
  36. }
  37.  
  38. void searching()       
  39. {
  40.     int count = 0;
  41.     for (short i=0; i<array_lenght; ++i) {
  42.         if ((array_num[i]&14) == 14) {
  43.             count = count + 1;
  44.             bool array_flag[i]=1;
  45.         }
  46.         else{
  47.             bool array_flag[i]=0;
  48.         }
  49.     }
  50.     cout<<"counter = "<<count;
  51. }
  52.  
  53. };
  54.  
  55.  
  56.  
  57. class SubClass:public BaseClass
  58. {
  59. protected:
  60. public:
  61. };
  62.  
  63. int main()
  64. {
  65.     BaseClass x;
  66.     x.create_array();  
  67.     x.print_array();
  68.     x.searching();
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment