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;
- short const array_lenght = 50;
- class BaseClass
- {
- private:
- 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 create_array(int a, int b)
- {
- srand(unsigned int (time(NULL)));
- b++;
- for (short i=0; i<array_lenght; ++i)
- {
- array_num[i]=( a + ((rand()+rand()) % (b - a)));
- }
- };
- 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 <<"\n" << array_flag[i] << std::endl;
- 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] & 20) == 20) {
- count = count + 1;
- array_flag[i]=true;
- }
- else{
- array_flag[i]=false;
- }
- }
- cout<<"counter = "<<count << std::endl;
- }
- };
- class SubClass:public BaseClass
- {
- private:
- std::string line;
- public:
- void read_file()
- {
- std::ifstream ist("input.txt");
- std::getline (ist,line);
- std::cout << "line: " << line <<"\n";
- }
- void remove_vowel()
- {
- for (unsigned int i = 0; i < line.length(); i++)
- {
- if ( line[i]=='a' || line[i]=='e' || line[i]=='y' || line[i]=='u' || line[i]=='i' || line[i]=='o')
- {
- for (unsigned int j = (0+i); j < line.length(); j++)
- {
- line[j]=line[j+1];
- }
- line.pop_back();
- i--;
- }
- }
- }
- void write_file()
- {
- std::ofstream ost("output.txt");
- cout<<"line after remove: ";
- for(unsigned int i=0;i<line.length();++i)
- {
- ost<<line[i];
- cout<<line[i];
- }
- }
- };
- int main()
- {
- BaseClass x;
- x.create_array();
- x.searching();
- x.print_array();
- SubClass y;
- y.read_file();
- y.remove_vowel();
- y.write_file();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment