Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream>
- #include<math.h>
- #include<stdlib.h>
- #include<string.h>
- using namespace std;
- class Bykvi{
- private:
- unsigned alfabet;
- public:
- Bykvi(){ alfabet=0; };
- Bykvi(char *);
- Bykvi operator*(Bykvi&);
- Bykvi operator~();
- operator char*();
- friend ostream& operator<<(ostream&,Bykvi&);
- };
- Bykvi Bykvi::operator*(Bykvi &p_b){
- Bykvi a;
- a.alfabet=alfabet&(p_b.alfabet);
- return(a);
- }
- Bykvi Bykvi::operator~(){
- Bykvi a;
- a.alfabet=~alfabet;
- return(a);
- }
- Bykvi::Bykvi(char *stroka){
- alfabet=0;
- while(*stroka){
- alfabet|=(1<<(tolower(*stroka)-'a'));
- stroka++;
- }
- }
- ostream& operator<<(ostream& out, Bykvi& a){
- unsigned bit=1;
- int i;
- for(i=0;i<26;i++){
- if(((a.alfabet)&bit)>0)
- out<<(char)('a'+i);
- else
- out<<" ";
- bit=bit*2;
- }
- return(out);
- }
- int main(int argc,char *argv[]){
- int i,j,k;
- Bykvi a,b;
- Bykvi **p;
- Bykvi itog("abcdefghijklmnopqrstuvwxyz");
- if(argc<2) return 0;
- p=new Bykvi*[argc-1];
- for(i=0;i<(argc-1);i++)
- p[i]=new Bykvi(argv[i]);
- cout<<itog<<endl;
- for(i=1;i<(argc-1);i++)
- for(j=i+1;j<(argc-1);j++){
- a=(*p[i])*(*p[j]);
- a=~a;
- itog=itog*a;
- }
- /*
- for(i=1;i<(argc-1);i++)
- for(j=i+1;j<(argc-1);j++){
- a=Bykvi(argv[i]);
- b=Bykvi(argv[j]);
- a=a*b;
- a=~a;
- itog=itog*a;
- // cout<<itog<<endl;
- }
- */
- cout<<itog<<endl;
- for(i=0;i<(argc-1);i++)
- delete p[i];
- delete []p;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement