fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int n;
  8. cin>>n;
  9. string s = bitset<8> (n).to_string();
  10. string v = s;
  11. for(int i=0;i<s.length();i++)
  12. {
  13. if(i%2 == 0)
  14. {
  15. v[i]=s[i+1];
  16. }else
  17. {
  18. v[i]=s[i-1];
  19. }
  20. }
  21. int number = 0;
  22. number = stoi(v,0,2);
  23. cout<<number;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5540KB
stdin
23
stdout
43