Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <iomanip>
- using namespace std;
- char A[5];
- int conv(){
- unsigned int B = 0;
- for(int i = 4, j = 0; i >= 0; i--, j++){
- unsigned int byte = 0;
- if(A[i]>='a' && A[i]<='f') byte = (10+A[i]-'a');
- else byte = (A[i]-'0');
- B |= (byte << (j*4));
- }
- return B;
- }
- int main()
- {
- cin.tie(0);
- ios_base::sync_with_stdio(false);
- unsigned int B = 0;
- while(1){
- for(int i = 0; i < 5; i++){
- cin >> A[i];
- if(A[i] == '.')goto printres;
- }
- B^=conv();
- }
- printres:;
- std::stringstream sstream;
- sstream << std::hex << B;
- std::string result = sstream.str();
- cout.fill('0');
- cout << setw(5) << result << endl;
- }
Add Comment
Please, Sign In to add comment