Advertisement
chiva13

Untitled

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