fork download
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. string siemaeniu(int a){
  6. string elo="";
  7. do{
  8. a%2==0?elo+='0':elo+='1';
  9. //cout << a%2 << " " << a << endl;
  10. a>>=1;
  11. }
  12. while(a);
  13. string relo="";
  14. for(int i=elo .length()-1;i>=0;i--){
  15. relo+=elo[i];
  16. }
  17. return relo;
  18. }
  19. int main(){
  20.  
  21. int n;
  22. cout<<"wprowadź zbiór w postaci liczby mordo"<<endl;
  23. cin>>n;
  24. cout << siemaeniu(n )<<endl;
  25. n|=3;
  26. cout<<siemaeniu(n)<<endl;
  27. n&=16;
  28. cout<<siemaeniu(n)<<endl;
  29.  
  30.  
  31.  
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 15240KB
stdin
1024
stdout
wprowadź zbiór w postaci liczby mordo
10000000000
10000000011
0