mardi 28 juin 2016

my c++ program is working ambigously.number is automatically changing into hexadecimal..pleease healp

my c++ program is working ambiguously.number is automatically changing into hexadecimal..please help

int main() {
    int t=0;
    cin>>t;
    while(t--)
        {
        int Q;
        string A,B,C;
        cin>>Q;
        cin>>hex>>A;
        cin>>hex>>B;
        cin>>hex>>C;

        string bit_A,bit_B,bit_C;
        bit_A=con(A);
        bit_B=con(B);
        bit_C=con(C);
        int k=0;
       for(unsigned i = 0; i != bit_B.length(); ++i)
               {

           if(bit_B[i]=='0' && bit_C[i]=='1' && bit_A[i]=='0'  )
               {

               bit_B[i]='1';
               k++;
               continue;
           }
           if(bit_C[i]=='0')
               {
               if(bit_B[i]=='1')
                   {
                   bit_B[i]='0';
               k++;
               }
               if(bit_A[i]=='1')
                   {
                   bit_A[i]='0';
                   k++;
               }
               continue;
           }
       }
        if(k>Q)
            {
            cout<<"-1";
            continue;
                }

       cout<<"value 0f k is"<<k<<endl;
         for(unsigned i = 0; k<Q && i != bit_A.length(); ++i)
               {
             if(bit_A[i]=='1' && bit_B[i]=='1')
                 {
                 bit_A[i]='0';
                 k++;
             }
             if(bit_A[i]=='1' && bit_B[i]=='0' && (Q-k)>=2)
                 {
                 bit_A[i]='0';
                 bit_B[i]='1';
                 k++;
                 k++;
             }
         }


         }



        cout<<std::uppercase<<hex<<todeci(bit_A)<<endl;
        cout<<std::uppercase<<hex<<todeci(bit_B)<<endl;
    }
    return 0;
}

here k value hacve changed automatically to hexa decimal which i cant figure out y?can anyone please help? 1 12 CAF7028FD 59B5AC1CE CAF1B7B7F for this input you will see k showing as B in output

Aucun commentaire:

Enregistrer un commentaire