Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //файл ristream.h
- #include <iostream>
- class Ristream{
- std::istream & in;
- unsigned length;
- bool space;
- public:
- Ristream(unsigned length=0, bool space=false, std::istream &in =std::cin):
- length(length), space(space), in(in){}
- Ristream& operator >> (int& i){
- i = rand()%100+rand()*100;
- i = (rand()%2==0)?i:-i;
- return *this;
- }
- Ristream& operator >> (unsigned & u){
- u = rand()%100+rand()*100;
- return *this;
- }
- Ristream& operator >> (double& d){
- d = 10.*rand()/RAND_MAX;
- d = (rand()%2==0)?d:-d;
- return *this;
- }
- void set_length(unsigned L){length=L;}
- unsigned get_length()const{return length;}
- void set_space(bool s){space =s;};
- bool get_space()const{return space;}
- Ristream& operator >> (char * str){
- char abc[] = "abcdefghijklmnopqrstuvwxyz ";
- for(unsigned i=0; i<length; i++)
- str[i] = space?abc[rand()%30]:abc[rand()%26];
- str[length] = '\0';
- return *this;
- }
- };
Add Comment
Please, Sign In to add comment