bobo_bobkata

Untitled

Sep 24th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. char A[5];
  8.  
  9. int conv(){
  10.     unsigned int B = 0;
  11.  
  12.     for(int i = 4, j = 0; i >= 0; i--, j++){
  13.         unsigned int byte = 0;
  14.         if(A[i]>='a' && A[i]<='f') byte = (10+A[i]-'a');
  15.         else byte = (A[i]-'0');
  16.         B |= (byte << (j*4));
  17.     }
  18.     return B;
  19. }
  20.  
  21. int main()
  22. {
  23.     cin.tie(0);
  24.     ios_base::sync_with_stdio(false);
  25.     unsigned int B = 0;
  26.     while(1){
  27.         for(int i = 0; i < 5; i++){
  28.             cin >> A[i];
  29.             if(A[i] == '.')goto printres;
  30.         }
  31.  
  32.         B^=conv();
  33.     }
  34.     printres:;
  35.     std::stringstream sstream;
  36.     sstream << std::hex << B;
  37.     std::string result = sstream.str();
  38.     cout.fill('0');
  39.     cout << setw(5) << result << endl;
  40. }
Add Comment
Please, Sign In to add comment