//Shruthi Kunjur
//3/5/20
//ACSL #3

#include
#include
#include
#include
#include
#include

using namespace std;

string irow[4][2]= {"B","~D","B","D","~B","D","~B","~D"};
string jrow[4][2]= {"A","~C","A","C","~A","C","~A","~C"};
string output[4][4];

ifstream myfile ("F://3int.txt");

int main()
{
    while (myfile){
        for (int i=0; i<4; i++){
            for (int j=0; j<4; j++){
                output[i][j]="0";
            }
        }
        string input;
        getline(myfile,input);
        vectorinputs;
        vectorletters;
        int place=0;                           ///breaking up string based on +
        int place1=0;
        string input1="";
        while (input.find('+',place)!= -1){
            if (place==0){
                place1= input.find('+',place);
                input1=input.substr(place,place1);
            }
            else{
                place1= input.find('+', place+1);
                input1= input.substr(place+1, place1-place-1);
            }
            place=place1;
            inputs.push_back(input1);
        }
        if (input.find('+')==-1)
        {
            inputs.push_back(input);
        }
        for (int i=0; ihexadecimal;
        for (int i=0; i<4; i++){   ///converting to hex
            string bin="";
            for (int j=0; j<4; j++){
                bin= bin + output[i][j];
            }
            int y=1;
            int hex=0;
            for (int c=3; c>=0; c--){
                hex= hex + (bin[c]-48)*y;
                y=y*2;
            }
            hexadecimal.push_back(hex);
        }
        for (int i=0; i<4; i++){
            if (hexadecimal[i]==10){
                cout<<"A";
            }
            else if (hexadecimal[i]==11){
                cout<<"B";
            }
            else if (hexadecimal[i]==12){
                cout<<"C";
            }
            else if (hexadecimal[i]==13){
                cout<<"D";
            }
            else if (hexadecimal[i]==14){
                cout<<"E";
            }
            else if (hexadecimal[i]==15){
                cout<<"F";
            }
            else if (hexadecimal[i]<10){
                cout<